Splitting JSON string

Hello Node-red.

I have been trying to split this JSON massage, to use the value for the dashboard. I have been searching in the forum and found topics but cant make it work.

Mqtt Tags


First feed it into a debug message and see what it shows. Make sure you tell the MQTT node to parse the JSON so that you get a javascript object.

Then there is a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.


This value is what i want
But i get this error

This is the code i put in a function node
JSON object

I copied the path from the the debug sidebar

You have a semi colon instead of a dot after msg

Also it should be
msg.payload = msg.payload....

1 Like

Thank you so much, it works!

Now that you have got it going in a function I will suggest potentially better ways (unless you are treating this as an educational exercise in learning javascript).

The first is to use a Change node set to Move msg.payload.values[0].v To msg.payload.

The third is to note that many of the dashboard nodes (the Gauge for example) allows you to specify which property you want to display. So you may be able to feed the existing payload straight into the dashboard node and, in the Value Format field, put {{payload.values[0].v}}

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.