# Not able to read a value from JSON object

**URL:** <https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083>\
**Category:** General\
**Created:** [29 August 2022 19:53 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083 "2022-08-29T19:53:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![b0denl0s](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/b0denl0s/32/67059_2.png) [@b0denl0s](https://discourse.nodered.org/u/b0denl0s)\
**Post date:** [29 August 2022 19:53 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/1 "2022-08-29T19:53:57Z")

</div>

Hi,

I am struggling since hours with a really basic job: Catching a simple value out of a JSON object. Not a big deal. I don't know what I am doing wrong...

JSON object passes in by _websocket in_ node (BTW: first time I am using this injection method).

Source is:

```auto
{
   "00000000-0000-0000-0000-000000000000":{
      "datapoints":{
         "ABB7F599D3C0/ch0000/idp0009":"17",
         "ABB702630C61/ch0000/odp0001":"17"
      },
      "devices":{
         
      },
      "devicesAdded":[
         
      ],
      "devicesRemoved":[
         
      ],
      "scenesTriggered":{
         
      }
   }
}

```

Debug node shows the following:

```auto
29.8.2022, 21:40:10node: e7771e114dcbd3d0
msg : Object
object
00000000-0000-0000-0000-000000000000: object
datapoints: object
ABB7F599D3C0/ch0000/idp0009: "17"
ABB702630C61/ch0000/odp0001: "17"
devices: object
empty
devicesAdded: array[0]
devicesRemoved: array[0]
scenesTriggered: object
empty
_session: object
type: "websocket"
id: "4942fe41c9a87306"
_msgid: "5b6849dcbb2015c4"

```

 ![nodered_debug_jsonobject](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6b37b35bc545f538d6021eeb841272dae43cf62.png)

-\>\> I tried several methods within functions, change, JSONata, (...) to catch the value "17" (datapoints.ABB7F599D3C0/ch0000/idp0009)

Nothing works. ☹  
Any suggestions what might be wrong? TIA!

---

<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:** [29 August 2022 20:08 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/2 "2022-08-29T20:08:50Z")

</div>

Welcome to the forum @b0denl0s

It isn't a JSON object, it is a javascript object. JSON is always a string.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

If you still can't get it going in a Change node or Function node then show us what you have tried.  
I suggest staying clear of JSONata until you have mastered other techniques.

---

<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:** [29 August 2022 20:16 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/3 "2022-08-29T20:16:52Z")

</div>

You could use JSONata to pull `ABB7F599D3C0/ch0000/idp0009` property value with [wildcard recursive](https://docs.jsonata.org/path-operators#-descendants) `$$.**.'ABB7F599D3C0/ch0000/idp0009'`

---

<div class="post-metadata">

**Author:** ![b0denl0s](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/b0denl0s/32/67059_2.png) [@b0denl0s](https://discourse.nodered.org/u/b0denl0s)\
**Post date:** [29 August 2022 20:25 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/4 "2022-08-29T20:25:37Z")

</div>

Thanks E1cid - that works!

---

<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:** [29 August 2022 20:32 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/5 "2022-08-29T20:32:02Z")

</div>

But have you learnt anything, so that next time you have a similar problem you will be able to do it without asking for help?

---

<div class="post-metadata">

**Author:** ![b0denl0s](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/b0denl0s/32/67059_2.png) [@b0denl0s](https://discourse.nodered.org/u/b0denl0s)\
**Post date:** [29 August 2022 20:45 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/6 "2022-08-29T20:45:02Z")

</div>

Not completely... But I am just workin on it... Still reading the docs you have linked...

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [29 August 2022 21:44 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/7 "2022-08-29T21:44:24Z")

</div>

Yes for these i normally use a switch node and switch on the property of the object and then send that out to different paths for different objects (you get this sort of structure with Tasmota on ESP devices with multiple DS18B20 temp sensors)

I find it much easier to come back in a years time and look at the switch node than try to understand what the Jsonata is doing - i have been struggling for a year or so and still do not use it regularly enough to master it

Craig

---

<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:** [12 September 2022 21:45 UTC](https://discourse.nodered.org/t/not-able-to-read-a-value-from-json-object/67083/8 "2022-09-12T21:45:03Z")

</div>

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