# Msg.payload assumption

**URL:** <https://discourse.nodered.org/t/msg-payload-assumption/15357>\
**Category:** Feature Requests\
**Created:** [10 September 2019 10:55 UTC](https://discourse.nodered.org/t/msg-payload-assumption/15357 "2019-09-10T10:55:04Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [11 September 2019 15:18 UTC](https://discourse.nodered.org/t/msg-payload-assumption/15357/21 "2019-09-11T15:18:35Z")

</div>

> [@bakman2](#):
>
> Lets say I receive data:
> 
> ```auto
> {
> "temperature":18,
> "humidity":60,
> "payload":"test"
> }
> 
> ```
> 
> Now I cannot access both the temperature and humidity at the same time using the switch node (perhaps with JSONata)

Indeed you _can_ use an expression in your `switch` node, and compare the results to match a set of output ports -- something like this, for instance, to detect some dewpoint condifion:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/cb58e5a15d63d3b39b8b66be222e43758b72999f.png)

The switch then sends the payload to port 1 if true, or port 2 if the condition is false:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/ae45a1294bdd53afedc5b21f2fae040071a992db.png)

And there is no reason why the expression could not return many "levels" of output (e.g. quartiles) that match up to multiple output ports -- much like a big "case" statement, but cooler!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [11 September 2019 15:33 UTC](https://discourse.nodered.org/t/msg-payload-assumption/15357/22 "2019-09-11T15:33:43Z")

</div>

Thanks, I am aware. I am mostly referring to the "new" `has key` option in the switch node, which makes it possible to 'route' by the key name.

[Previous page](https://discourse.nodered.org/t/msg-payload-assumption/15357.md?page=1)
