# Msg.payload in json

**URL:** <https://discourse.nodered.org/t/msg-payload-in-json/12339>\
**Category:** General\
**Created:** [17 June 2019 20:03 UTC](https://discourse.nodered.org/t/msg-payload-in-json/12339 "2019-06-17T20:03:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duncan](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Duncan](https://discourse.nodered.org/u/Duncan)\
**Post date:** [17 June 2019 20:03 UTC](https://discourse.nodered.org/t/msg-payload-in-json/12339/1 "2019-06-17T20:03:17Z")

</div>

easy question for you all. I am trying to set a variable: msg.payload: 10, in a json format. The msg.payload : 10 must replace the "timeout" : 20  
{  
"payload": "on",  
"timeout": 20,  
"warning": 5  
}  
thanks.

---

<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:** [17 June 2019 20:12 UTC](https://discourse.nodered.org/t/msg-payload-in-json/12339/2 "2019-06-17T20:12:32Z")

</div>

Hi @Duncan

Just to clarify, you want to set `msg.payload` to the object:

```auto
{
   "payload": "on",
   "timeout": 20,
   "warning": 5
}

```

but you want to replace the `timeout` value (`20` in the example) with the existing value of `msg.payload`?

If that is the case, then a Function node with the follow would do it:

```auto
msg.payload = {
   "payload": "on",
   "timeout": msg.payload,
   "warning": 5
}
return msg;

```

If that isn't what you meant, then maybe you could clarify.

---

<div class="post-metadata">

**Author:** ![Duncan](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Duncan](https://discourse.nodered.org/u/Duncan)\
**Post date:** [17 June 2019 20:20 UTC](https://discourse.nodered.org/t/msg-payload-in-json/12339/3 "2019-06-17T20:20:14Z")

</div>

> [@knolleary](#):
>
> msg.payload = { "payload": "on", "timeout": msg.payload, "warning": 5 } return msg;

exactly what I meant, thanks it works. I might just get the hang of this eventually.
