# Extract multiple variables from a JSON object

**URL:** <https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554>\
**Category:** General\
**Created:** [29 September 2018 10:04 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554 "2018-09-29T10:04:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [29 September 2018 10:04 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/1 "2018-09-29T10:04:38Z")

</div>

Hi,

Please could someone help me to extract a number of variable values from a JSON object returned by my home automation controller - please see screen shot attached

To start with I’m looking to extract the values you can see opened, I’ve tried a functions with variations of msg.payload[0][0][0] but I only get errors. A kick in the right direction would be appreciated (many thanks)

Extract of JSON below.

```
{ "Device_Num_22": { "states": [{ "id": 167, "service": "urn:upnp-org:serviceId:SwitchPower1", "variable": "Status", "value": "0" }, { "id": 168, "service": "urn:upnp-org:serviceId:Dimming1", "variable": "LoadLevelStatus", "value": "0" }, { "id": 169, "service": "urn:upnp-org:serviceId:Dimming1", "variable": "LoadLevelTarget", "value": "0" }, { "id": 170, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "Configured", "value": "1" }, { "id": 171, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "LastUpdate", "value": "1455968462" }, { "id": 172, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "FirstConfigured", "value": "1341655010" }, { "id": 173, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "CommFailure", "value": "1" }, { "id": 174, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Capabilities", "value": "211,156,0,4,17,1,L,R,B,RS,|38:1,39,112,114,115,133,134,142," }, { "id": 175, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ManufacturerInfo", "value": "271,256,262" }, { "id": 176, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "VersionInfo", "value": "3,3,34,1,6" }, { "id": 177, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "NodeInfo", "value": "26,27,70,72,73,85,86,8e," }, { "id": 178, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ConfiguredAssoc", "value": "" }, { "id": 179, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollSettings", "value": "60" }, { "id": 180, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Neighbors", "value": "1,10,37,41," }, { "id": 181, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastReset", "value": "1455968460" }, { "id": 182, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AssociationNum", "value": "3" }, { "id": 183, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollOk", "value": "9" }, { "id": 184, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastRouteUpdate", "value": "1538138819" }, { "id": 185, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "VariablesSet", "value": "14,1d,1" }, { "id": 186, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "VariablesGet", "value": "14,1," }, { "id": 187, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "SensorMlType", "value": "" }, { "id": 188, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "SensorMlScale", "value": "" }, { "id": 189, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "NeighborsInverse", "value": "" }, { "id": 190, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Health", "value": "" }, { "id": 191, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AutoRoute", "value": "0-5x,10-15,26-15,20-16" }, { "id": 192, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AllRoutesFailed", "value": "0" }, { "id": 193, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MultiChEndpoint", "value": "" }, { "id": 194, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MultiChCapabilities", "value": "" }, { "id": 195, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ConfiguredName", "value": "" }, { "id": 196, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MeterType", "value": "" }, { "id": 197, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MeterScale", "value": "" }, { "id": 198, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "SetPointInfo", "value": "" }, { "id": 199, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollTxFail", "value": "" }, { "id": 200, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "HealthDate", "value": "1443490454" }, { "id": 201, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ConfiguredVariable", "value": "14,1d,1" }, { "id": 202, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollNoReply", "value": "15" }, { "id": 203, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastWakeup", "value": "1491467301" }, { "id": 204, "service": "urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "variable": "CurrentSetpoint", "value": "21" }], "Jobs": [], "tooltip": { "display": 0 }, "status": -1 }, "LoadTime": 1537623966, "DataVersion": 624293835, "UserData_DataVersion": 623966640, "TimeStamp": 1538157549, "ZWaveStatus": 1, "LocalTime": "2018-09-28 18:59:09 N" }

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d60a6d013104d035dd93b69d7bdcfb30b9041c44.jpeg)

I’m working on an idea that I could extract specific variables from calls made to my HA controler and then use them in some text to speech flows i’m working on too.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 September 2018 10:12 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/2 "2018-09-29T10:12:26Z")

</div>

The docs have a guide on understanding the structure of a message: [https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message](https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message)

In particular, it explains how the debug sidebar can be used to get the full path to any message element copied straight to your clipboard.

Nick

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [29 September 2018 10:36 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/3 "2018-09-29T10:36:45Z")

</div>

Thanks Nick

I recall looking at this now,

> [@knolleary](#):
>
> the debug sidebar can be used to get the full path to any message element copied straight to your clipboard.

One point of feedback, on the above feature is that these buttons do not seem to work on my iPad with Safari, I’ve tried numerous times but it would not appear in the clipboard.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/992ad10bbb1000ce5f1731b88923ecfdcfaf471f.jpeg)

Ok, the above works for one value, but I missed a key point in my question above, in that I will be calling different devices, so the example above is device 22, is there a wild card that can be used for the first part, so I can run different JSON calls via the same function ?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [29 September 2018 11:40 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/4 "2018-09-29T11:40:37Z")

</div>

if you google “javascript wildcard” you’ll find loads of tutorials that will help you

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [29 September 2018 15:28 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/5 "2018-09-29T15:28:25Z")

</div>

What do you get as output if you inject your msg.payload to this change node ?

![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9a39c2fac295be7cf154700420e9c253f45515e8.png)

```auto
[{"id":"c28f4e65.7b03f","type":"tab","label":"Flow 7","disabled":false,"info":""},{"id":"78dc82cc.d458bc","type":"change","z":"c28f4e65.7b03f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"**.states[18].value","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":160,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 September 2018 15:35 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/6 "2018-09-29T15:35:31Z")

</div>

> [@nodecentral](#):
>
> iPad with Safari

Unfortunately, Safari is a long way behind current standards I think. Also security is different on mobile devices.

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [29 September 2018 17:42 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/7 "2018-09-29T17:42:11Z")

</div>

Many thanks @Andrei, that looks good and seems to do the trick nicely 😁.

I had looked up various things online about how to do javascript wildcards; but as I’m not a programmer - it talked about regex and other things, which I struggle with to apply - I had hoped it would be as simple as an asterix ‘ \* ‘ - If I see working examples of how things are done in the area I’m looking to use them - I find I work out and build on things best that way ..

Thanks again

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [29 September 2018 17:50 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/8 "2018-09-29T17:50:40Z")

</div>

Taking it one step further, I had hoped this would work so I could start dissecting the JSON into individual values I could then work with .. is there a way to do this within a single node ? (I looked at the split node but that does not look like it will help.)

Or is the only way via separate Change nodes?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1f3f556d4084ceda2e6f835255f44e61a6e17e74.jpeg)

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [29 September 2018 21:55 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/9 "2018-09-29T21:55:00Z")

</div>

> [@nodecentral](#):
>
> dissecting the JSON into individual values I could then work with

Perhaps it is possible to build another jsonata expression (a little bit more complex). I will give it a try.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [30 September 2018 04:31 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/10 "2018-09-30T04:31:45Z")

</div>

Well, just changing the expression as below may achieve both goals: a) use only one node and b) extract the values...

```auto
**.states[[18..19]].value

```

However I am not sure if this will help you at the end of the day. The above will produce an array with the extracted values but you will not know to which Device\_Num and state the values are associated.

As a matter of fact there are other possible solutions but the best one will ultimately depend on how you will process the information downstream. Also I am not sure that you will always want to extract the values from status[18] and status[19]. If you change this requirement you will need to come up with a new jsonata expression. Perhaps if you restate your requirements in a broader way (by saying all that you may ever need to extract and how you will process it later on) then we may realize how to transform the original dataset to easy the solution.

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [30 September 2018 07:35 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/11 "2018-09-30T07:35:27Z")

</div>

Thanks again for your help on this @Andrei

What I’m trying to do is create a (human understandable) device report / health message, one that can either be sent out via email, or a notification (Prowl) or spoken (via text to speech).

So on demand I can then request (or schedule) a specific device name/number to be called - and the flow would then extract the required variable values to populate key parts of the health message.

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [29 July 2019 14:00 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/12 "2019-07-29T14:00:53Z")

</div>

Hi - resurfacing an old one of mine to ask the question if it's possible (based on the JSON being returned (see first post) to search for "variables" by name, and have its associated "value" returned ?

Example; lets say I want to know the value associated with for the "LastWakeUp" variable ?

(Due to the different types of devices available, the object numbers that are assigned to the JSON that's returned in NR could be different, but the variable name seems to be consistant - so searching by names could be better - if possible to do ?)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 July 2019 14:54 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/13 "2019-07-29T14:54:14Z")

</div>

Quick bodge way of doing it  
Scan the JSON to find mention of LastWakeup and then output the next item

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7976299c08d48b48fc6631dcacd44deee3d3df86.png)

```auto
[{"id":"66476e1b.c9162","type":"inject","z":"58f97b48.255ef4","name":"","topic":"","payload":"{ \"Device_Num_22\": { \"states\": [{ \"id\": 167, \"service\": \"urn:upnp-org:serviceId:SwitchPower1\", \"variable\": \"Status\", \"value\": \"0\" }, { \"id\": 168, \"service\": \"urn:upnp-org:serviceId:Dimming1\", \"variable\": \"LoadLevelStatus\", \"value\": \"0\" }, { \"id\": 169, \"service\": \"urn:upnp-org:serviceId:Dimming1\", \"variable\": \"LoadLevelTarget\", \"value\": \"0\" }, { \"id\": 170, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"Configured\", \"value\": \"1\" }, { \"id\": 171, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"LastUpdate\", \"value\": \"1455968462\" }, { \"id\": 172, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"FirstConfigured\", \"value\": \"1341655010\" }, { \"id\": 173, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"CommFailure\", \"value\": \"1\" }, { \"id\": 174, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"Capabilities\", \"value\": \"211,156,0,4,17,1,L,R,B,RS,|38:1,39,112,114,115,133,134,142,\" }, { \"id\": 175, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ManufacturerInfo\", \"value\": \"271,256,262\" }, { \"id\": 176, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"VersionInfo\", \"value\": \"3,3,34,1,6\" }, { \"id\": 177, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"NodeInfo\", \"value\": \"26,27,70,72,73,85,86,8e,\" }, { \"id\": 178, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ConfiguredAssoc\", \"value\": \"\" }, { \"id\": 179, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollSettings\", \"value\": \"60\" }, { \"id\": 180, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"Neighbors\", \"value\": \"1,10,37,41,\" }, { \"id\": 181, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"LastReset\", \"value\": \"1455968460\" }, { \"id\": 182, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"AssociationNum\", \"value\": \"3\" }, { \"id\": 183, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollOk\", \"value\": \"9\" }, { \"id\": 184, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"LastRouteUpdate\", \"value\": \"1538138819\" }, { \"id\": 185, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"VariablesSet\", \"value\": \"14,1d,1\" }, { \"id\": 186, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"VariablesGet\", \"value\": \"14,1,\" }, { \"id\": 187, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"SensorMlType\", \"value\": \"\" }, { \"id\": 188, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"SensorMlScale\", \"value\": \"\" }, { \"id\": 189, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"NeighborsInverse\", \"value\": \"\" }, { \"id\": 190, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"Health\", \"value\": \"\" }, { \"id\": 191, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"AutoRoute\", \"value\": \"0-5x,10-15,26-15,20-16\" }, { \"id\": 192, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"AllRoutesFailed\", \"value\": \"0\" }, { \"id\": 193, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MultiChEndpoint\", \"value\": \"\" }, { \"id\": 194, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MultiChCapabilities\", \"value\": \"\" }, { \"id\": 195, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ConfiguredName\", \"value\": \"\" }, { \"id\": 196, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MeterType\", \"value\": \"\" }, { \"id\": 197, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MeterScale\", \"value\": \"\" }, { \"id\": 198, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"SetPointInfo\", \"value\": \"\" }, { \"id\": 199, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollTxFail\", \"value\": \"\" }, { \"id\": 200, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"HealthDate\", \"value\": \"1443490454\" }, { \"id\": 201, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ConfiguredVariable\", \"value\": \"14,1d,1\" }, { \"id\": 202, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollNoReply\", \"value\": \"15\" }, { \"id\": 203, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"LastWakeup\", \"value\": \"1491467301\" }, { \"id\": 204, \"service\": \"urn:upnp-org:serviceId:TemperatureSetpoint1_Heat\", \"variable\": \"CurrentSetpoint\", \"value\": \"21\" }], \"Jobs\": [], \"tooltip\": { \"display\": 0 }, \"status\": -1 }, \"LoadTime\": 1537623966, \"DataVersion\": 624293835, \"UserData_DataVersion\": 623966640, \"TimeStamp\": 1538157549, \"ZWaveStatus\": 1, \"LocalTime\": \"2018-09-28 18:59:09 N\" }","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":100,"wires":[["8dda075f.df1c38"]]},{"id":"529f7bd2.e07384","type":"debug","z":"58f97b48.255ef4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":100,"wires":[]},{"id":"8dda075f.df1c38","type":"json","z":"58f97b48.255ef4","name":"","property":"payload","action":"str","pretty":false,"x":290,"y":100,"wires":[["bb5ea8d3.c3fa28"]]},{"id":"bb5ea8d3.c3fa28","type":"csv","z":"58f97b48.255ef4","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"","skip":"0","x":430,"y":100,"wires":[["c2fbbd39.1352c"]]},{"id":"a6a2796e.564c58","type":"switch","z":"58f97b48.255ef4","name":"","property":"last","propertyType":"flow","rules":[{"t":"eq","v":"variable:LastWakeup","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":100,"wires":[["529f7bd2.e07384"]]},{"id":"c2fbbd39.1352c","type":"function","z":"58f97b48.255ef4","name":"","func":"var j, newmsg;\n\n\nvar j_list = (msg['payload']);\nfor (var j_index in j_list) {\n j = j_list[j_index];\n newmsg={};\n newmsg['payload'] = j;\n flow.set('last', (flow.get('current')));\n flow.set('current', (newmsg['payload']));\n node.send([newmsg]);\n}\n","outputs":1,"noerr":0,"x":570,"y":100,"wires":[["a6a2796e.564c58"]]}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 July 2019 21:59 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/14 "2019-07-29T21:59:49Z")

</div>

> [@nodecentral](#):
>
> LastWakeUp

Well, your original data didn't have that property (which is the correct term for what you are calling "variable").

However, if you wanted to get all of the `variable` properties 😉 from Device\_Num\_22, you could use:

```auto
Device_Num_22.*.variable

```

Or if you want that property from ALL devices as a single list:

```auto
*.*.variable

```

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [30 July 2019 13:18 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/15 "2019-07-30T13:18:57Z")

</div>

Updated my bodge to use `payload.*.*.*` to produce a clean array of the data instead of the csv and split nodes

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d5406cca11c01dc11c8d64d7e8a6a9603d45ad7d.png)

```auto
[{"id":"66476e1b.c9162","type":"inject","z":"58f97b48.255ef4","name":"","topic":"","payload":"{ \"Device_Num_22\": { \"states\": [{ \"id\": 167, \"service\": \"urn:upnp-org:serviceId:SwitchPower1\", \"variable\": \"Status\", \"value\": \"0\" }, { \"id\": 168, \"service\": \"urn:upnp-org:serviceId:Dimming1\", \"variable\": \"LoadLevelStatus\", \"value\": \"0\" }, { \"id\": 169, \"service\": \"urn:upnp-org:serviceId:Dimming1\", \"variable\": \"LoadLevelTarget\", \"value\": \"0\" }, { \"id\": 170, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"Configured\", \"value\": \"1\" }, { \"id\": 171, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"LastUpdate\", \"value\": \"1455968462\" }, { \"id\": 172, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"FirstConfigured\", \"value\": \"1341655010\" }, { \"id\": 173, \"service\": \"urn:micasaverde-com:serviceId:HaDevice1\", \"variable\": \"CommFailure\", \"value\": \"1\" }, { \"id\": 174, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"Capabilities\", \"value\": \"211,156,0,4,17,1,L,R,B,RS,|38:1,39,112,114,115,133,134,142,\" }, { \"id\": 175, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ManufacturerInfo\", \"value\": \"271,256,262\" }, { \"id\": 176, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"VersionInfo\", \"value\": \"3,3,34,1,6\" }, { \"id\": 177, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"NodeInfo\", \"value\": \"26,27,70,72,73,85,86,8e,\" }, { \"id\": 178, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ConfiguredAssoc\", \"value\": \"\" }, { \"id\": 179, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollSettings\", \"value\": \"60\" }, { \"id\": 180, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"Neighbors\", \"value\": \"1,10,37,41,\" }, { \"id\": 181, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"LastReset\", \"value\": \"1455968460\" }, { \"id\": 182, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"AssociationNum\", \"value\": \"3\" }, { \"id\": 183, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollOk\", \"value\": \"9\" }, { \"id\": 184, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"LastRouteUpdate\", \"value\": \"1538138819\" }, { \"id\": 185, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"VariablesSet\", \"value\": \"14,1d,1\" }, { \"id\": 186, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"VariablesGet\", \"value\": \"14,1,\" }, { \"id\": 187, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"SensorMlType\", \"value\": \"\" }, { \"id\": 188, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"SensorMlScale\", \"value\": \"\" }, { \"id\": 189, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"NeighborsInverse\", \"value\": \"\" }, { \"id\": 190, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"Health\", \"value\": \"\" }, { \"id\": 191, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"AutoRoute\", \"value\": \"0-5x,10-15,26-15,20-16\" }, { \"id\": 192, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"AllRoutesFailed\", \"value\": \"0\" }, { \"id\": 193, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MultiChEndpoint\", \"value\": \"\" }, { \"id\": 194, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MultiChCapabilities\", \"value\": \"\" }, { \"id\": 195, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ConfiguredName\", \"value\": \"\" }, { \"id\": 196, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MeterType\", \"value\": \"\" }, { \"id\": 197, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"MeterScale\", \"value\": \"\" }, { \"id\": 198, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"SetPointInfo\", \"value\": \"\" }, { \"id\": 199, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollTxFail\", \"value\": \"\" }, { \"id\": 200, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"HealthDate\", \"value\": \"1443490454\" }, { \"id\": 201, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"ConfiguredVariable\", \"value\": \"14,1d,1\" }, { \"id\": 202, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"PollNoReply\", \"value\": \"15\" }, { \"id\": 203, \"service\": \"urn:micasaverde-com:serviceId:ZWaveDevice1\", \"variable\": \"LastWakeup\", \"value\": \"1491467301\" }, { \"id\": 204, \"service\": \"urn:upnp-org:serviceId:TemperatureSetpoint1_Heat\", \"variable\": \"CurrentSetpoint\", \"value\": \"21\" }], \"Jobs\": [], \"tooltip\": { \"display\": 0 }, \"status\": -1 }, \"LoadTime\": 1537623966, \"DataVersion\": 624293835, \"UserData_DataVersion\": 623966640, \"TimeStamp\": 1538157549, \"ZWaveStatus\": 1, \"LocalTime\": \"2018-09-28 18:59:09 N\" }","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":100,"wires":[["1297fe8a.84eac1"]]},{"id":"529f7bd2.e07384","type":"debug","z":"58f97b48.255ef4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":100,"wires":[]},{"id":"a6a2796e.564c58","type":"switch","z":"58f97b48.255ef4","name":"","property":"last","propertyType":"flow","rules":[{"t":"eq","v":"LastWakeup","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":100,"wires":[["529f7bd2.e07384"]]},{"id":"c2fbbd39.1352c","type":"function","z":"58f97b48.255ef4","name":"","func":"var j, newmsg;\n\n\nvar j_list = (msg['payload']);\nfor (var j_index in j_list) {\n j = j_list[j_index];\n newmsg={};\n newmsg['payload'] = j;\n flow.set('last', (flow.get('current')));\n flow.set('current', (newmsg['payload']));\n node.send([newmsg]);\n}\n","outputs":1,"noerr":0,"x":490,"y":100,"wires":[["a6a2796e.564c58"]]},{"id":"1297fe8a.84eac1","type":"change","z":"58f97b48.255ef4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.*.*.*","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":100,"wires":[["c2fbbd39.1352c"]]}]

```

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [30 July 2019 15:46 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/17 "2019-07-30T15:46:58Z")

</div>

Thanks @cymplecy

---

<div class="post-metadata">

**Author:** ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)\
**Post date:** [22 February 2021 16:13 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/18 "2021-02-22T16:13:21Z")

</div>

Hi, I have a similar problem. Can you help me please how can I extract "teplota" to graph? my json file looks like this:

({"teplota":7.85159,"vlhkost":73.5749,"oblacnost":0,"vietor":0,"tlak":1029.28,"smer":"JZ","pocitovo":6.32,"pocasie":"01d","vychod":"06:37","zapad":"17:15","cas":"Pondelok 22.2. 17:09","zrazky24":0});

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 February 2021 18:22 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/19 "2021-02-22T18:22:54Z")

</div>

Is your data actually in parenthesizes? Where did you get that data from?  
If that is from a `debug` node, can you show the entire output.

---

<div class="post-metadata">

**Author:** ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)\
**Post date:** [22 February 2021 20:40 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/20 "2021-02-22T20:40:06Z")

</div>

here is my debug:  
`{"topic":"meteostanica","payload":"({\"teplota\":2.10504,\"vlhkost\":91.7815,\"oblacnost\":0,\"vietor\":0,\"tlak\":1032.47,\"smer\":\"JZ\",\"pocitovo\":0.12,\"pocasie\":\"01n\",\"vychod\":\"06:37\",\"zapad\":\"17:15\",\"cas\":\"Pondelok 22.2. 21:37\",\"zrazky24\":0});","statusCode":200,"headers":{"server":"nginx","date":"Mon, 22 Feb 2021 20:37:27 GMT","content-type":"application/json","transfer-encoding":"chunked","connection":"close","x-powered-by":"PHP/7.3.17","x-node-red-request-node":"35516f00"},"responseUrl":"http://meteosasova.sk/bbo_api.php","redirectList":[],"parts":{"id":"f493c65f.a65c48","type":"string","ch":"\n","index":2,"count":3},"_msgid":"9eca6895.a904f8","label":"sasova"}`

and here is my complete flow:

```auto
[{"id":"1a2d781c.46fa4","type":"tab","label":"Weather","disabled":false,"info":""},{"id":"e275a8a5.6029b8","type":"inject","z":"1a2d781c.46fa4","name":"make request","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":100,"y":80,"wires":[["aaf7ab1c.57a3e"]]},{"id":"25dd6728.b352c8","type":"debug","z":"1a2d781c.46fa4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":120,"wires":[]},{"id":"aaf7ab1c.57a3e","type":"http request","z":"1a2d781c.46fa4","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://meteosasova.sk/bbo_api.php","tls":"","persist":false,"proxy":"","authType":"","x":190,"y":30,"wires":[["da84b8a7.59e13"]]},{"id":"71a1ee05.00e1f","type":"json","z":"1a2d781c.46fa4","name":"","property":"payload","action":"str","pretty":true,"x":340,"y":120,"wires":[["429836e1.7d4568"]]},{"id":"429836e1.7d4568","type":"file","z":"1a2d781c.46fa4","name":"chart","filename":"homie/homey-5ac5f38e42b2c4296e150d77/tester","appendNewline":false,"createDir":true,"overwriteFile":"true","x":460,"y":130,"wires":[["af7ad592.ac9f18"]]},{"id":"2f80eb1c.584794","type":"file in","z":"1a2d781c.46fa4","name":"chart","filename":"homie/homey-5ac5f38e42b2c4296e150d77/tester","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":590,"y":70,"wires":[["a5e9bc66.d78a7"]]},{"id":"714e54e1.d9d134","type":"inject","z":"1a2d781c.46fa4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":590,"y":20,"wires":[["2f80eb1c.584794"]]},{"id":"af7ad592.ac9f18","type":"debug","z":"1a2d781c.46fa4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":180,"wires":[]},{"id":"ed17743.b16b308","type":"ui_chart","z":"1a2d781c.46fa4","name":"","group":"8ac23c9c.86f8a8","order":13,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":880,"y":50,"wires":[[]]},{"id":"44e5ee4.4aba71","type":"change","z":"1a2d781c.46fa4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"meteostanica","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"sasova","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":80,"wires":[["71a1ee05.00e1f"]]},{"id":"a5e9bc66.d78a7","type":"change","z":"1a2d781c.46fa4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"meteostanica","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"sasova","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":80,"wires":[["ed17743.b16b308","25dd6728.b352c8"]]},{"id":"da84b8a7.59e13","type":"split","z":"1a2d781c.46fa4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"payload","x":350,"y":30,"wires":[["44e5ee4.4aba71"]]},{"id":"8ac23c9c.86f8a8","type":"ui_group","z":"","name":"Outside weather","tab":"98a2ef12.9e1df","order":1,"disp":false,"width":21,"collapse":false},{"id":"98a2ef12.9e1df","type":"ui_tab","z":"","name":"Weather","icon":"fa-sun-o","order":5,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 February 2021 20:59 UTC](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554/21 "2021-02-22T20:59:02Z")

</div>

Please don't open another thread when you have already started a [thread about this](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435). I am closing this thread as it is two years old.

[Next page](https://discourse.nodered.org/t/extract-multiple-variables-from-a-json-object/3554.md?page=2)
