# Switch node and Object message

**URL:** <https://discourse.nodered.org/t/switch-node-and-object-message/7706>\
**Category:** General\
**Created:** [7 February 2019 12:12 UTC](https://discourse.nodered.org/t/switch-node-and-object-message/7706 "2019-02-07T12:12:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [7 February 2019 12:32 UTC](https://discourse.nodered.org/t/switch-node-and-object-message/7706/2 "2019-02-07T12:32:46Z")

</div>

Hi @SuperNinja

The Switch node can be used to route the entire message to different outputs based on the different rules you create. It does not modify the structure of the message.

You need to use a Split node first. When it receives msg.payload as an Object, it will emit a new message for each key/value pair in that object. You can configure the node to copy the key value to `msg.topic`.

You can then use a Switch node to check `msg.topic` and add a rule for each of the topics you are getting.

By the way, please read this post on sharing code in the forum: [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

_[View the full topic](https://discourse.nodered.org/t/switch-node-and-object-message/7706)._
