Msg.payload format

How to make msg.payload from the top payload like on the bot ?
image

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

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
PI UART:
image
Func:
image
image

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:

global.set("UID", msg.payload.trim());
1 Like

Thanks, it work.