Passing data to MQTT node


#1

I’m a bit confused as to how the MQTT node works with a custom topic in comparison to publishing to /losant.

With the node it seems it does not place a an object in the payload which my device is publishing. I have structured data to pass through a workflow from MQTT and I’m wondering the typical use of the data field which appears to just be a string. My structured Jason data is just coming through as a flat string with “\” between fields. How can I pass data in without having to later parse it?


#2

When using non-Losant topics, we don’t enforce any specific format. This was designed to allow legacy devices to continue publishing in any existing format, which is then parsed by the workflow. It’s fairly common for devices to publish raw bytes in order to keep the payload size as small as possible.

Because of this, we aren’t able to perform any automatic parsing of the data. Unfortunately we just don’t have a way to know the data format.

When using Losant topics, we enforce a JSON data structure, which means we can automatically parse it.

If you’re passing JSON data over a non-Losant topic, you’ll have to use the JSON: Decode Node to parse it into an object on the payload.