# Unable to read value from object

**URL:** <https://discourse.nodered.org/t/unable-to-read-value-from-object/24867>\
**Category:** General\
**Created:** [15 April 2020 11:50 UTC](https://discourse.nodered.org/t/unable-to-read-value-from-object/24867 "2020-04-15T11:50:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Birdy](https://avatars.discourse-cdn.com/v4/letter/b/85e7bf/32.png) [@Birdy](https://discourse.nodered.org/u/Birdy)\
**Post date:** [15 April 2020 11:50 UTC](https://discourse.nodered.org/t/unable-to-read-value-from-object/24867/1 "2020-04-15T11:50:25Z")

</div>

Hi,

I have this specific JSON-Object:

```auto
15.4.2020, 13:46:47node: 8ab35232.361e7
tele/TB01_Orgon/SENSOR : msg : Object
object
topic: "tele/TB01_Orgon/SENSOR"
payload: object
Time: "2020-04-15T12:46:47"
SDS0X1: object
PM2.5: 3.7
PM10: 6.9
qos: 0
retain: false
_msgid: "142a99e1.7fd376"

```

I try to read the PM2.5 and the PM10 values from the object like this:

```auto
msg.PM25 = msg.payload.SDS0X1+".PM2.5";
msg.PM10 = msg.payload.SDS0X1+".PM10";

```

But the output I get looks like this ... and that's not what I want 😃

```auto
PM25: "[object Object].PM2.5"
PM10: "[object Object].PM10"

```

Any ideas whats going wrong here ?  
BR  
Birdy

---

<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:** [15 April 2020 12:14 UTC](https://discourse.nodered.org/t/unable-to-read-value-from-object/24867/2 "2020-04-15T12:14:56Z")

</div>

The statement:

```auto
msg.PM25 = msg.payload.SDS0X1+".PM2.5";

```

Is asking it to turn `msg.payload.SDS0X1` into a String and then join the string `".PM2.5"` to the end of it. Because `msg.payload.SDS0X1` is an Object, when it gets converted to a string, you get `"[object Object]"`.

The syntax you need is:

```auto
msg.PM25 = msg.payload.SDS0X1["PM2.5"]
msg.PM10 = msg.payload.SDS0X1["PM10"]

```

If you haven't already, its worth reading this page of the docs - [https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

It explains how, using the Debug sidebar, you can get the path to any element of a message.

---

<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:** [29 April 2020 12:19 UTC](https://discourse.nodered.org/t/unable-to-read-value-from-object/24867/3 "2020-04-29T12:19:45Z")

</div>

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