# Switch node issue

**URL:** <https://discourse.nodered.org/t/switch-node-issue/10266>\
**Category:** General\
**Created:** [16 April 2019 22:53 UTC](https://discourse.nodered.org/t/switch-node-issue/10266 "2019-04-16T22:53:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelview](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@pixelview](https://discourse.nodered.org/u/pixelview)\
**Post date:** [16 April 2019 22:53 UTC](https://discourse.nodered.org/t/switch-node-issue/10266/1 "2019-04-16T22:53:23Z")

</div>

Hi,

I'm trying to get the switch node to read in a json message from a sigfox callback and send a twillio message based on the data.

The messages can be of 3 types:  
first type:  
{  
"data":"{c0}"

}  
second type:  
{  
"data":"{c0ff}"

}  
third type:  
{  
"data":"{c0ffee}"

}

what setup of the switch node would allow me to route the messages based on the data content. I tried the most logical combinations to my mind but I either get no routing or all 3 are routed.

\*note : the message data is in hex I don't know if that changes anything If it does I can change it.  
Any help would be greatly appreciated  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/ce563433ded9eda976543548b8e610ae47c84617.png)

---

<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:** [16 April 2019 23:04 UTC](https://discourse.nodered.org/t/switch-node-issue/10266/2 "2019-04-16T23:04:21Z")

</div>

Hi @pixelview - welcome.

In your description you say the data properties are `"{c0}"` etc - but the screenshots show you testing for `"c0"`. I assume the former is a typo?

I suggest you change the Property field of the switch node to be `msg.payload.data` and then you can use the `==` check for the string value `c0` etc.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 April 2019 06:12 UTC](https://discourse.nodered.org/t/switch-node-issue/10266/3 "2019-04-17T06:12:30Z")

</div>

Could you feed the data into a debug node and copy/paste the result please, to check _exactly_ what the data consists of.

---

<div class="post-metadata">

**Author:** ![pixelview](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@pixelview](https://discourse.nodered.org/u/pixelview)\
**Post date:** [17 April 2019 06:58 UTC](https://discourse.nodered.org/t/switch-node-issue/10266/4 "2019-04-17T06:58:25Z")

</div>

Sorry about the confusion. This the data copied from debug {"data":"c0ff"}  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a4cb7e3a1e60ab6d60f564134740a4ec65f11dc4.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 April 2019 08:24 UTC](https://discourse.nodered.org/t/switch-node-issue/10266/5 "2019-04-17T08:24:34Z")

</div>

Right, so the payload is not JSON (which is a string) but is a javascript object. So in the switch node you just need, for example  
`msg.payload.data == "c0ff"`  
No JSON involved.

---

<div class="post-metadata">

**Author:** ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)\
**Post date:** [17 April 2019 08:25 UTC](https://discourse.nodered.org/t/switch-node-issue/10266/6 "2019-04-17T08:25:02Z")

</div>

It looks like the property should be set to msg.payload.data rather than just msg.payload, and then you would just compare with strings (not JSONata) - i.e. == c0, contains c0ff, or == c0ffee (it doesn't look like this last one should be a JSONata expression). Note that "c0ffee" would match the 2nd and 3rd case, so the result would depend on whether you have "checking all rules" or "stopping on first match" (in which case the 3rd would never occur).
