# Msg.payload format

**URL:** <https://discourse.nodered.org/t/msg-payload-format/2423>\
**Category:** General\
**Created:** [20 August 2018 18:45 UTC](https://discourse.nodered.org/t/msg-payload-format/2423 "2018-08-20T18:45:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Popo21](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@Popo21](https://discourse.nodered.org/u/Popo21)\
**Post date:** [20 August 2018 18:45 UTC](https://discourse.nodered.org/t/msg-payload-format/2423/1 "2018-08-20T18:45:07Z")

</div>

How to make msg.payload from the top payload like on the bot ?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a82d6ad728d29c46b4528891562cb91fd6a590b1.png)

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [20 August 2018 18:56 UTC](https://discourse.nodered.org/t/msg-payload-format/2423/2 "2018-08-20T18:56:25Z")

</div>

Can you explain better what you have and what you wanted? If you take an inject node and just select string and set as payload this value you directly have this.

I guess you wanted to edit and add or remove the "" but if you don't explain better...

Regards

---

<div class="post-metadata">

**Author:** ![Popo21](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@Popo21](https://discourse.nodered.org/u/Popo21)\
**Post date:** [20 August 2018 20:16 UTC](https://discourse.nodered.org/t/msg-payload-format/2423/3 "2018-08-20T20:16:43Z")

</div>

Sorry for that, my scenario is like this, I want compare 2 value, 1 from PI UART, and the other is from SQLite. I use global context which the result like two image above. Top payload from UART and bottom payload from SQLite. When I use two of that value which I want compare each other, the output value always false.  
SQLite:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9629a5a1568548ba7b6f0251e40615cc1d094527.png)  
PI UART:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2fbff15dcb902326b5fdf9323279eb4b915eb64a.png)  
Func:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f2d09df5906b01f6214b4164d1b27c66f0f13dfd.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e96178adf64dd1c2ab2a8f25624187942835e100.jpeg)

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [21 August 2018 02:37 UTC](https://discourse.nodered.org/t/msg-payload-format/2423/4 "2018-08-21T02:37:28Z")

</div>

My guess is that the PI UART is generating a Buffer of four characters, converting them to the hex digits shown in the top image, and returning a newline terminated string (which is why they are shown inside that grey box instead of double quotes.

What node(s) are you using to get the data from the UART? Perhaps if you posted that part of your flow, someone could take a better guess...

IF the only difference between the strings is the line terminator character, trim the string from the UART before you save it to the global variable, like so:

```auto
global.set("UID", msg.payload.trim());

```

---

<div class="post-metadata">

**Author:** ![Popo21](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@Popo21](https://discourse.nodered.org/u/Popo21)\
**Post date:** [21 August 2018 06:10 UTC](https://discourse.nodered.org/t/msg-payload-format/2423/5 "2018-08-21T06:10:04Z")

</div>

Thanks, it work.
