How to extract several bits of data from a json(?) string(?)

A local LAN url returns a message like this:

{"data":{"did":"001D0A712D46","ts":1613228819,"conditions":[{"lsid":352807,"data_structure_type":1,"txid":1,"temp": 32.2,"hum":57.2,"dew_point": 18.7,"wet_bulb": 26.6,"heat_index": 31.2,"wind_chill": 24.3,"thw_index": 23.3,<<<snip>>>

A Function Node extracts one bit of data (temp) & I then forward it to my MQTT broker, but how might I extract several bits, ie temp, hum, wet_bulb etc etc.

msg.payload = msg.payload.data.conditions[0].temp;
return msg;

TIA

To send as a JSON

msg.payload = {"temp":msg.payload.data.conditions[0].temp,
"hum":msg.payload.data.conditions[0].hum,"wet_bulb":msg.payload.data.conditions[0].wet_bulb};

Or to send all the condition array

msg.payload = msg.payload.data.conditions[0];
1 Like

Brilliant - many thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.