# Null instead of undefined

**URL:** <https://discourse.nodered.org/t/null-instead-of-undefined/32490>\
**Category:** General\
**Created:** [6 September 2020 05:01 UTC](https://discourse.nodered.org/t/null-instead-of-undefined/32490 "2020-09-06T05:01:20Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Daneev](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daneev/32/10874_2.png) [@Daneev](https://discourse.nodered.org/u/Daneev)\
**Post date:** [6 September 2020 10:14 UTC](https://discourse.nodered.org/t/null-instead-of-undefined/32490/21 "2020-09-06T10:14:21Z")

</div>

> [@ristomatti](#):
>
> `msg.payload = {foo: undefined, bar: null};`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/42e6d8850ecf2ea954637ce199236b74c5f24d5b.png)

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 September 2020 10:19 UTC](https://discourse.nodered.org/t/null-instead-of-undefined/32490/22 "2020-09-06T10:19:22Z")

</div>

Yep the debug node statuses work fine (as it's just a string of text like Dave mentioned). Debug tab has the other property "missing".

Edit: sorry missed half of your screenshot. Interesting indeed, so it's any JSON serialisation that has the issue. I think I've actually also run across this at work when serializing objects to JS frontend from a Java backend.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 September 2020 10:25 UTC](https://discourse.nodered.org/t/null-instead-of-undefined/32490/23 "2020-09-06T10:25:00Z")

</div>

Ah, `undefined` is not valid JSON: [https://stackoverflow.com/a/14946821](https://stackoverflow.com/a/14946821)

Well that explains a lot. You learn something every day. 🙂

---

<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:** [6 September 2020 10:25 UTC](https://discourse.nodered.org/t/null-instead-of-undefined/32490/24 "2020-09-06T10:25:09Z")

</div>

`undefined` is not a valid JSON type, so if you do a straight JSON stringify of an object, you won't get any properties whose value is undefined.

This is why the debug sidebar has to do a lot more work to display values beyond a smple stringify.

---

<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:** [5 November 2020 10:25 UTC](https://discourse.nodered.org/t/null-instead-of-undefined/32490/25 "2020-11-05T10:25:10Z")

</div>

Closed on 5 November 2020 10:25 UTC

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

[Previous page](https://discourse.nodered.org/t/null-instead-of-undefined/32490.md?page=1)
