# Parsing JSON data with hexadecimal values

**URL:** <https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794>\
**Category:** General\
**Created:** [6 December 2021 22:21 UTC](https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794 "2021-12-06T22:21:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DNicholai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dnicholai/32/52163_2.png) [@DNicholai](https://discourse.nodered.org/u/DNicholai)\
**Post date:** [6 December 2021 22:21 UTC](https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794/1 "2021-12-06T22:21:33Z")

</div>

I'm trying to parse a JSON value, the value is as follows :

_{"ZbReceived":{"0xF063":{"Device":"0xF063","Name":"Sonoff\_Motion\_sensor","0500\<00":"000000000000","ZoneStatusChange":0,"Occupancy":0,"Endpoint":1,"LinkQuality":45}}}_

I'm interested in the value of Occupancy, and normally converting the result to JSON and then accessing the value as follows would work :

_var newMsg = { payload: msg.payload.ZbReceived.0xF062.Occupancy };_  
_return newMsg;_

However, the above code gives an error of " **Unexpected '.'.**"

What is the proper escape character in order to convince Node Red to behave as expected?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 December 2021 22:26 UTC](https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794/2 "2021-12-06T22:26:44Z")

</div>

I think you may need to put the message through the `JSON` node and then it may be more usable.

Oh, edit your post and use the `</>` button to post the message.

Makes it easier for others.

---

<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:** [6 December 2021 22:55 UTC](https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794/3 "2021-12-06T22:55:04Z")

</div>

If you used the Microsoft alternate code editor instead of ACE, you would have seen the error 😉

You can't have a plain property name that starts with a number. So to access that data, you need:

```auto
return {
    payload: msg.payload.ZbReceived["0xF063"].Occupancy
}

```

---

<div class="post-metadata">

**Author:** ![DNicholai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dnicholai/32/52163_2.png) [@DNicholai](https://discourse.nodered.org/u/DNicholai)\
**Post date:** [8 December 2021 21:55 UTC](https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794/4 "2021-12-08T21:55:08Z")

</div>

Thanks @TotallyInformation, that worked great ^^

The node red code ended up being :

```auto
if (msg.payload.ZbReceived['0xF062'].Device == '0xF062'){
    var newMsg = { payload: msg.payload.ZbReceived['0xF062'].Occupancy };
    return newMsg;   
} else {
    return null;
}

```

---

<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:** [6 February 2022 21:55 UTC](https://discourse.nodered.org/t/parsing-json-data-with-hexadecimal-values/54794/5 "2022-02-06T21:55:27Z")

</div>

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