# Guide to using JSON option in change node

**URL:** <https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478>\
**Category:** General\
**Created:** [22 August 2018 13:41 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478 "2018-08-22T13:41:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [22 August 2018 13:41 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478/1 "2018-08-22T13:41:55Z")

</div>

I basically would like to amalgamate two items into a combined JSON object/string

e.g

I've got msg.tweethandle and msg.tweettxt - how do I use the JSON option in the change node to make msg.payload = { msg.tweethandle : msg.tweettxt} (the contents of them - not those literal words)

Or is that not what its for?

or have I lost the JSON plot entirely again?

Simon

---

<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:** [22 August 2018 14:23 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478/2 "2018-08-22T14:23:09Z")

</div>

The JSON option doesn't include any way to reference the received message properties when constructing its object.

You should use the Expression option instead:

```
{$.tweethandle: $.tweettxt}
```

---

<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:** [22 August 2018 14:29 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478/3 "2018-08-22T14:29:53Z")

</div>

If you use the JSONata option (J:) you can Set msg.payload To msg.tweethandle&msg.tweettxt which will concatenate the two strings.

[Edit] I see I misread the requirement. ☹

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [22 August 2018 14:50 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478/4 "2018-08-22T14:50:15Z")

</div>

Ta for info

I've ended up with this as I realised I needed to have fixed keys for each value (and I even surpassed myself by working out that I needed a JSON node to convert it to an object afterwards 🙂 )

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 August 2018 15:22 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478/5 "2018-08-22T15:22:55Z")

</div>

You should be able to do that with just the JSONata I think.

From [this example](https://it.knightnet.org.uk/kb/nr-qa/jsonata/#extract-specific-element-from-a-context-variable), you can see that you can access both the topic and the payload directly.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [22 August 2018 15:39 UTC](https://discourse.nodered.org/t/guide-to-using-json-option-in-change-node/2478/7 "2018-08-22T15:39:20Z")

</div>

> [@TotallyInformation](#):
>
> You should be able to do that with just the JSONata I think.

Of course - I was just taking little steps one at a time 🙂
