Parsing a JSON file


I am getting the JSON below from my boiler and zould like to extract the L_statetext value.


I am using the following in a change mode but this doesn't work:

$split(payload.pe1.L_statetext, ',')

The first thing to confirm is whether you have a JSON string, or if it has already been parsed into a JavaScript Object.

If you pass that message to a Debug node, it if shows as a single blob of text, then it is a JSON string. In which case, you will need to pass it through the JSON node to convert it to a JavaScript Object.

Once you have it as an object, then you can use a Change node to set msg.payload to the value of msg.payload.pe1.L_statetext - there is no need to use $split or any other JSONata expression.

Thanks mate,

using the JSON node to convert it to a JavaScript Object was the way to go.

Thank you so much

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