I am trying to get my data into my IoT Hub on Azure from a Modbus signal.
My flow is as follows:
[{"id":"a40d774a.bf8648","type":"azureiothub","z":"53f246d7.f619f8","name":"Azure IoT Hub","protocol":"mqtt","x":780,"y":120,"wires":[[]]},{"id":"99bdb067.08498","type":"function","z":"53f246d7.f619f8","name":"","func":"msg.payload = msg.payload.split(\",\");\nmsg1 = '{\"deviceID\": \"WaveBuoy\", '\nmsg1 = msg1 + '\"SAK\": \"PrimaryKey=\", ' \nmsg1 = msg1 + '\"Protocol\": \"mqtt\", '\nmsg1 = msg1 + '\"Data\": { \"' + msg.topic + '\": \"' + msg.payload[4] + '\": \"' + msg.payload[5] + '\": \"'+ msg.payload[6] + '\"}}'\n\nnewMsg = { payload: msg1 };\nreturn newMsg;\n\nmsg1 = msg1 + '\"Data\": { \"' + msg.topic + '\": \"' + msg.payload + '\"}}'","outputs":1,"noerr":0,"x":370,"y":280,"wires":[["4073cbfd.cf8d14","a40d774a.bf8648"]]},{"id":"beb2fc2f.9da3b","type":"tcp in","z":"53f246d7.f619f8","name":"","server":"client","host":"xxx","port":"xxx","datamode":"stream","datatype":"utf8","newline":"","topic":"WaveBuoy","base64":false,"x":150,"y":280,"wires":[["99bdb067.08498"]]}]
I am getting the following error:
msg : error
"SyntaxError: Unexpected token : in JSON at position 129
or 128
My string looks like this:
"{"deviceID": "WaveBuoy", "SAK": "PrimaryKey=", "Protocol": "mqtt", "Data": { "WaveBuoy": "0.01": "0.02": "0.09"}}"
If anyone could aid me it would be very much appreciated.