# How to split the payload? temp and pressure values from JSON string (from aws)

**URL:** <https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324>\
**Category:** General\
**Created:** [15 July 2019 23:43 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324 "2019-07-15T23:43:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![RhinePT](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@RhinePT](https://discourse.nodered.org/u/RhinePT)\
**Post date:** [15 July 2019 23:43 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/1 "2019-07-15T23:43:19Z")

</div>

Hey everybody

I get that message on the debug:

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

What I really want is to know how to split the values of temp and pressure. Is needed a function? If yes, what's the code?  
I've read user-guide/messages link but didnt get a conclusion.

The dashboard will stay simple like this:

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

Really appreciated!

---

<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:** [15 July 2019 23:55 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/2 "2019-07-15T23:55:47Z")

</div>

Try:

 ![19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a1f07023d5271694db673bb8d7627cccc30ef32b.jpeg)

---

<div class="post-metadata">

**Author:** ![RhinePT](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@RhinePT](https://discourse.nodered.org/u/RhinePT)\
**Post date:** [16 July 2019 14:11 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/3 "2019-07-16T14:11:08Z")

</div>

But which nodes I connect with? I've got an inject node with the values that comes from mqtt then I connect it to a function node and then to the mqtt output node?

 ![orca](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7f8c10118c4f2d15e2ad0c9ebec49b26df4afa12.jpeg)

 ![orca](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/46892a33179d867a0dfed7e3b19c558a709629e8.jpeg)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 July 2019 14:20 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/4 "2019-07-16T14:20:44Z")

</div>

The screenshot you posted today shows that your data is a string because of the return characters you have in it (the arrows)  
The best thing to do would be to make sure they are removed before you send . Then the MQTT node should be able to convert the message into a javascript object and you will then be able to display it properly.

---

<div class="post-metadata">

**Author:** ![RhinePT](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@RhinePT](https://discourse.nodered.org/u/RhinePT)\
**Post date:** [16 July 2019 14:35 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/5 "2019-07-16T14:35:06Z")

</div>

So you're saying I should get, like the first screenshot, _Temp: "25"_ (object) rather than _"Temp": "25"_ (string) ?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 July 2019 14:51 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/6 "2019-07-16T14:51:44Z")

</div>

You need it as a javascript object in Node-RED. Given that's what you in the first post I'd suggest changing back to what you had first,  
If you are sending via MQTT the MQTT node with automatically convert a JSON string into a javascript object. Currently it isn't doing that because of the carriage returns

---

<div class="post-metadata">

**Author:** ![RhinePT](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@RhinePT](https://discourse.nodered.org/u/RhinePT)\
**Post date:** [16 July 2019 16:27 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/7 "2019-07-16T16:27:16Z")

</div>

I'll change it back for what I did first and after that, the split can be done with a function node or a change node? Cause I just want to put the temperature on a gauge and the pressure on another.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [16 July 2019 16:39 UTC](https://discourse.nodered.org/t/how-to-split-the-payload-temp-and-pressure-values-from-json-string-from-aws/13324/8 "2019-07-16T16:39:45Z")

</div>

If you are sending a valid JSON message through the MQTT node will convert it to a javascript object.  
There should be no need for a split node.

You can the use a debug be to find the correct path to the data you want to visualise. The “working with messages” page in the docs will show you how (see @bakman2 reply…)

If you don’t understand javascript objects it is worth working through an online tutorial as it’s fundamental for working with Node-RED
