# Switch from json not working for me

**URL:** <https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251>\
**Category:** General\
**Created:** [7 March 2023 17:22 UTC](https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251 "2023-03-07T17:22:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alveron](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@alveron](https://discourse.nodered.org/u/alveron)\
**Post date:** [7 March 2023 17:22 UTC](https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251/1 "2023-03-07T17:22:27Z")

</div>

Really basic but it is not working for me  
Here is a snippet of the flow I am working with  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6e3d53ea8b612d87e68ff9f7bc607a6829b24a4c.png)

here is the switch node setup  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c47a051162ec2bf0b76982105dca7db05707c4d5.png)

Here is the debug messages

```auto
3/7/2023, 12:16:23 PMnode: debug 8
fdrs/data : msg.payload : string[39]
"{"id":1,"type":3,"data":32,"time":9067}"
3/7/2023, 12:16:23 PMnode: debug 8
fdrs/data : msg.payload : string[48]
"{"id":1,"type":1,"data":22.06900024,"time":9067}"

```

As you can see I am getting nothing from the switch statement... what am I missing ?

---

<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:** [7 March 2023 17:24 UTC](https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251/2 "2023-03-07T17:24:44Z")

</div>

Your payload is a string not an object remove or bypass the json node.

---

<div class="post-metadata">

**Author:** ![alveron](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@alveron](https://discourse.nodered.org/u/alveron)\
**Post date:** [7 March 2023 17:29 UTC](https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251/3 "2023-03-07T17:29:52Z")

</div>

ok, thanks, So the json setup it says convert to a json string and object.  
What object does it refer to ?

---

<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:** [7 March 2023 17:31 UTC](https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251/4 "2023-03-07T17:31:41Z")

</div>

standard setting of json node is :-  
if payload is an object convert to string.  
if payload is a string convert to object.

you can set it to always do one or the other to.

---

<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 May 2023 17:31 UTC](https://discourse.nodered.org/t/switch-from-json-not-working-for-me/76251/5 "2023-05-06T17:31:58Z")

</div>

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