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

**URL:** <https://discourse.nodered.org/t/how-to-extract-several-bits-of-data-from-a-json-string/40935>\
**Category:** General\
**Created:** [13 February 2021 15:12 UTC](https://discourse.nodered.org/t/how-to-extract-several-bits-of-data-from-a-json-string/40935 "2021-02-13T15:12:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haskle](https://avatars.discourse-cdn.com/v4/letter/h/e19adc/32.png) [@haskle](https://discourse.nodered.org/u/haskle)\
**Post date:** [13 February 2021 15:12 UTC](https://discourse.nodered.org/t/how-to-extract-several-bits-of-data-from-a-json-string/40935/1 "2021-02-13T15:12:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [13 February 2021 15:25 UTC](https://discourse.nodered.org/t/how-to-extract-several-bits-of-data-from-a-json-string/40935/2 "2021-02-13T15:25:25Z")

</div>

To send as a JSON

```auto
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

```auto
msg.payload = msg.payload.data.conditions[0];

```

---

<div class="post-metadata">

**Author:** ![haskle](https://avatars.discourse-cdn.com/v4/letter/h/e19adc/32.png) [@haskle](https://discourse.nodered.org/u/haskle)\
**Post date:** [13 February 2021 15:44 UTC](https://discourse.nodered.org/t/how-to-extract-several-bits-of-data-from-a-json-string/40935/3 "2021-02-13T15:44:56Z")

</div>

Brilliant - many thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 February 2021 15:45 UTC](https://discourse.nodered.org/t/how-to-extract-several-bits-of-data-from-a-json-string/40935/4 "2021-02-27T15:45:24Z")

</div>

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