Parse an array within an object in node red

1,075 views
Skip to first unread message

scott mcclelland

unread,
Oct 3, 2017, 3:18:26 PM10/3/17
to Node-RED

Hi 

i cannot find how to parse the rxInfo array within this object so i can access the parameters 

i normally collect the payload (Data:) using 


msg.payload = msg.payload.data.toString();
return msg;


I have been looking at toArray but can't manage to get working


02/10/2017, 23:19:57node: MQTT debugapplication/1/node/0101010101010102/rx : msg.payload : Object
object
applicationID"1"
applicationName"AndersonMoyPark-RHF1S001"
nodeName"RHF1S001-Anderson-PoultryHouse1"
devEUI"0101010101010102"
rxInfoarray[1]
0object
mac"b827ebfffe7afb93"
rssi-121
loRaSNR-10.2
name"LoRaWAN-38"
latitude54.86658090934141
longitude-6.167278289794922
altitude170
txInfoobject
frequency868100000
dataRateobject
modulation"LORA"
bandwidth125
spreadFactor12
adrtrue
codeRate"4/5"
fCnt616
fPort8
data"AQReqMIB//++"

thanks in advance for any light you can shed

Nick O'Leary

unread,
Oct 3, 2017, 3:36:28 PM10/3/17
to Node-RED Mailing List
Assuming you're using Node-RED 0.17, when you hover over an element of the message in debug you will see some buttons appear to the right hand-side:



Clicking the first of them will copy the path to that element (excluding the intial 'msg'). For example, from the text you've pasted, I _think_ you'll find rxInfo is addressed as msg.payload.rxInfo.

In which case msg.payload.rxInfo[0] is the first element in that array - as you have expanded in the view.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/bf007959-656c-4140-888a-76abbac97b9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

scott mcclelland

unread,
Oct 3, 2017, 5:40:40 PM10/3/17
to Node-RED
Perfect pulled out the object i wanted

thanks for your help

Phil Taylor

unread,
Jan 17, 2018, 1:03:10 AM1/17/18
to Node-RED
Me too!  Thanks Nick, great feature.
Reply all
Reply to author
Forward
0 new messages