Message payload as float-array?

Is it possible to define the payload of a message as a float-array ? I need that to publish some MQTT data where the MQTT payload has to be a float-array.

Hi @abra

the payload of an MQTT message is raw bytes - so you have to decide how you want to encode your data.

If you pass an array to the the MQTT Out node, it will JSON encode it to a string representation of the data.

So if msg.payload is the array [1.5, 2.7, 3.0], it will be stringified as JSON: [1.5, 2.7, 3]

The stringifing to JSON will cause floats like 3.0 to be represented as 3 - that can cause problems for some receiving libraries that cannot handle 3 as a float. If that is the case, you'd have to create your own string representation of the array that preserved the 3.0 in the text.