# Parsing an object, when part of it isn't "object-y"

**URL:** <https://discourse.nodered.org/t/parsing-an-object-when-part-of-it-isnt-object-y/29043>\
**Category:** General\
**Created:** [26 June 2020 19:55 UTC](https://discourse.nodered.org/t/parsing-an-object-when-part-of-it-isnt-object-y/29043 "2020-06-26T19:55:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![impvan](https://avatars.discourse-cdn.com/v4/letter/i/8797f3/32.png) [@impvan](https://discourse.nodered.org/u/impvan)\
**Post date:** [26 June 2020 19:55 UTC](https://discourse.nodered.org/t/parsing-an-object-when-part-of-it-isnt-object-y/29043/1 "2020-06-26T19:55:26Z")

</div>

Received MQTT message is converted using the JSON node and gives this output:

```auto
tele/Hetty/SENSOR : msg.payload : Object
object
  Time: "2020-06-26T20:36:58"
  DS18B20-1: object
    Id: "030197946C6B"
    Temperature: 21.6

```

I can extract the ID value, because it's enclosed in " ". I _can't_ seem to extract the 'Temperature' value, it isn't enclosed in quotes...I get 'undefined' errors.

Question: how to handle the '21.6' value which is formatted differently to the other values...

---

<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:** [26 June 2020 20:03 UTC](https://discourse.nodered.org/t/parsing-an-object-when-part-of-it-isnt-object-y/29043/2 "2020-06-26T20:03:09Z")

</div>

How are you trying to access it? The fact it doesn't have quotes just means its value is a number rather than a string - it doesn't affect how to access it.

To get to the ID, you would use `msg.payload["DS18B20-1"].Id`.  
Similarly, the Temperature is `msg.payload["DS18B20-1"].Temperature`.

This page in the docs describes how you can use the Debug sidebar to get the path to any message element - [https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![impvan](https://avatars.discourse-cdn.com/v4/letter/i/8797f3/32.png) [@impvan](https://discourse.nodered.org/u/impvan)\
**Post date:** [26 June 2020 21:00 UTC](https://discourse.nodered.org/t/parsing-an-object-when-part-of-it-isnt-object-y/29043/3 "2020-06-26T21:00:07Z")

</div>

I _had_ been using the 'path' button, which helped with understanding the Object structure.

My main issue seems to have been using the **switch** node to select on **string**"DS18B20-1" - when using the string option, don't need the quotes...

I now have an output message containing just 'Id' and 'temp value'. That'll do for now!

---

<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:** [10 July 2020 21:02 UTC](https://discourse.nodered.org/t/parsing-an-object-when-part-of-it-isnt-object-y/29043/4 "2020-07-10T21:02:16Z")

</div>

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