# Change node not working as I expected

**URL:** <https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584>\
**Category:** General\
**Created:** [8 December 2018 15:03 UTC](https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584 "2018-12-08T15:03:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [8 December 2018 15:03 UTC](https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584/1 "2018-12-08T15:03:03Z")

</div>

Hi I am trying to recreate the following format  
object  
topic: "owl"  
payload: object  
Name: "53"  
IP: "27"  
so I understand that to get the IP from this result I would access msg.payload.IP fine!

But how do I recreate the input to produce this result

I have a function node with msg.payload="27" then I have a change node with set msg.payload.IP to msg.payload but it doesn't create the payload:object or the IP what am I doing wrong.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [8 December 2018 15:14 UTC](https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584/2 "2018-12-08T15:14:55Z")

</div>

You first used msg.payload to store a string, and that is fine. Then you want to use msg.payload to be an object with property IP. Indeed, that is not possible. You can not add properties to a string.

A simple solution is to delete msg.payload in the change node, as shown below:

![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fbfc3ae871841da7faaaabc5bac1086eaadf7a70.png)

or alternatively:

![r-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/14608c7618dc6c9749becf0001c49ff5cad7721f.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:** [8 December 2018 15:22 UTC](https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584/3 "2018-12-08T15:22:48Z")

</div>

I thought that Move msg.payload to msg.payload.ip would work but not at my pc so can't check.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [8 December 2018 15:25 UTC](https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584/4 "2018-12-08T15:25:53Z")

</div>

Hi Colin,

Indeed, and this would be the best choice, in my opinion 🙂

![r-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/272163c61622ffa9b9ef884aab6cac34ca81267d.png)

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [8 December 2018 19:11 UTC](https://discourse.nodered.org/t/change-node-not-working-as-i-expected/5584/5 "2018-12-08T19:11:10Z")

</div>

Yep that's sorted it thanks
