Issue parsing MQTT data


I have an MQTT node configured which is pulling data from a Victron Inverter. I'm receiving the payload in the following format:

2/15/2019, 5:11:26 PMnode: 73afd856.bf16c8N/removed_my_portal_id/battery/258/Soc : msg.payload : string[15]

"{"value": 98.5}"

When attempting to output msg.payload.value, i get an undefined value which i believe is due to the outer quotes. Any advice?

Thanks, Kirk



Hi @rvexodus

you have a JSON String there, not a JavaScript object. Note it says string[15] and there are "quotes" around it.

If you add a JSON node to the flow after the MQTT node, it will parse the string and set msg.payload to the Object it represents - which you will then be able to do msg.payload.value.

See also:



I want to say in the back of my mind I suspected it may be json but wasn't sure how to handle it .... didn't realize simply inserting the json node with no other changes would do the trick. THANK YOU for the help knolleary!