Hello all,
New guy here. Thanks in advance for any help you can offer.
I'm trying to ingest an MQTT stream and extract / remap some of the values. I've only used msg.payload.split but can't quite get the formatting right. I thought about nested scrubbing of the stream but I figured there must be a better way.
Any ideas on how I can cleanly parse the payload is very much appreciated.
How do you want to parse it?
Are you in control of sending the data in the first place? if so why not format it how you want before sending it?
It looks like you are receiving an string that contains a array that contains an object. If you take the output of the mqtt in and send it thru the json node, you will convert the string to an array. If you send that to a change node you could set msg.payload to msg.payload[0]. Now you will have an object you could now access the parts with msg.payload.timestamp or msg.payload.sourceId
Hi Paul,
Thanks for the quick reply.
Adding in the JSON step converted the string to an object and I can access the msg components individually and with the proper formatting now.
Thank you
JG