[Solved] String delimiter setting for Mosquitto broker



This inquiry perhaps should be directed to the Mosquitto forum but I found that many reported "issues" there have been dormant for several months and hence need your indulgence here. I'm trying to get off the ground with basic MQTT orchestration. So far, the Python code (pub & sub) is doing the limited stuff that I need. However, in transporting to Node-RED workflows I've run into a beginner issue with the message that is imported by the MQTT sub/input node. The issue is not with the node but the strings used in the message from the broker.

The mosquitto broker is replacing all strings published with the quote character (") to the apostrophe character (') when forwarding the messages to the subscribers.

The publish command in use uses the following string for the message payload:
myData = {
"DeviceId": "DS180B20-08-28",
"Status": 0,
"Reading": 19.2,
"Dimension": "Temperature",
"UOM": "C"
payload = str(myData)
publish.single( topic, payload, qos, client_id, keepalive, will, auth, tls, protocol, transport)

The subscriber receives it as:
{'DeviceId': 'DS180B20-08-28', 'Status': 2, 'Dimension': 'Temperature', 'Reading': 19.2, 'UOM': 'C'}

JSON.parse complains about the string delimiter when I try to work with the payload in a node widget. I've glanced at the mosquitto documentation but could not find any setting to suppress this unwanted conversion. Is there any such setting?

How could I use a Function node (or any other node for that matter, e.g. JSON) to derive a JSON object to flow through the downstream nodes?




Issue closed. Sorry about the false alarm. I used json.dumps() in the publish client (instead of str() owing to my limited understanding) and no string delimiter issue was visible anymore.