Payload address has a decimal (period)

Hello,

I am receiving these data from a sensor:

{
"pm25": 27,
"pm10": 30,
"pm1.0": 20,
"temperature": 17.5,
"humidity": 35.5
}

I have success in getting the data using below code, as an example:

var newMsg = { payload: msg.payload.pm10 };

My problem comes from the data for pm1.0, I cannot type

var newMsg = { payload: msg.payload.pm1.0 };

As the "." will be like a separator. Tried doing this but still does not work:

var newMsg = { payload: msg.payload."pm1.0" };

A bit new to Node-red, not really sure how to resolve this. Big thanks to anyone who will help!

There’s 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.

BX00Cy7yHi

Hi Steve,

Thanks a lot, very helpful for me.

By the way, just found the solution to my problem, I just needed to change the code to this:
var newMsg = { payload: msg.payload["pm1.0"] };

Thanks!

Which is what the methods in the linked page would have allowed you to determine.

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