Possible bug in json node?

I am using a Sonoff Bridge and some 433 MHz buttons.

Two buttons work without any error. This is the output from the RF Bridge:
{"Time":"2020-11-11T17:17:45","RfReceived":{"Sync":13070,"Low":420,"High":1260,"Data":"DD80F1","RfKey":"None"}}
{"Time":"2020-11-11T17:24:30","RfReceived":{"Sync":13060,"Low":420,"High":1260,"Data":"DD80F8","RfKey":"None"}}

But, these two buttons produce an error from the json node:
"Unexpected token O in JSON at position 0"
This is the output from the RF Bridge:
{"Time":"2020-11-11T17:16:36","RfReceived":{"Sync":13050,"Low":420,"High":1250,"Data":"DD80F8","RfKey":"None"}}
{"Time":"2020-11-11T17:22:37","RfReceived":{"Sync":13070,"Low":420,"High":1260,"Data":"DD80F4","RfKey":"None"}}

The data from all four buttons looks virtually the same, so why am I getting the error from the json node on two of them?

Here is my test flow:
rf-bridge_flow

[{"id":"b24b6fa8.2a3c3","type":"mqtt in","z":"eb64de9a.f978e","name":"RF Bridge","topic":"tele/bridge1/RESULT","qos":"0","datatype":"auto","broker":"52bf28e2.c2a1e8","x":580,"y":1280,"wires":[["e0304c46.991e7","b1faf87e.608748"]]},{"id":"e0304c46.991e7","type":"json","z":"eb64de9a.f978e","name":"","property":"payload","action":"","pretty":false,"x":710,"y":1280,"wires":[["397f1ed6.cea942"]]},{"id":"397f1ed6.cea942","type":"function","z":"eb64de9a.f978e","name":"Just the data","func":"// just the data\nvar myData = msg.payload.RfReceived.Data;\nmsg.payload = myData;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":1280,"wires":[["b78ce0dd.d030e"]]},{"id":"b78ce0dd.d030e","type":"debug","z":"eb64de9a.f978e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":1280,"wires":[]},{"id":"b1faf87e.608748","type":"debug","z":"eb64de9a.f978e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":1220,"wires":[]},{"id":"52bf28e2.c2a1e8","type":"mqtt-broker","broker":"192.168.1.124","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

Please post a screenshot of the debug node output showing the MQTT node output and the error.

[Edit] Also when posting flows please use the </> button at the top of the text entry window when pasting it in, that ensures that the forum does not mess with the text. You can fix this in your previous post by editing it and inserting a line with three backtick characters before the flow and another such line after it.

Sorry, forgot the <>. It's been a while since I posted a flow on the forum...

Examining the debug node outputs closer tells me that there is no bug in the json node.

Here is the screenshot showing the debug nodes. The debug output is from the nodes in sequence, left-to-right.

The first three are what I expect to see from button "A". The second three are what I expect from button "B". The last two were unexpected. I do not know why the bridge output is sending a payload of "on", but that is likely why the json node is throwing an error.

I need to investigate now why the bridge is sending the payload of "on".

Note, part of my assumption of a bug was because I did not pay attention to the sequence of the debug nodes. When I deleted the debug nodes and reinserted them in sequence, the problem was much more clear.

Thanks for the response, and apologize for the false alarm.

The output in debug nodes can be confusing as sometimes they can come out in what appears to be wrong order. The other trick is to get into the habit of giving debug nodes names, then it is easier to see which is which in the output.

Once you get it sorted then you should be able to set the MQTT node Output to Parsed JSON so that it will parse the string for you and give you a js object, so you won't need the JSON node.

I am getting the exact same error. Have you figured it out? I see that it is because of the follow-on string that the bridge is sending. But I have not found a setting on the bridge to stop it. BTW, I did notice that your Rfkeys are not defined.

If you just want to ignore those messages then add a switch node that only passes on messages where the first character is "{".

Thanks. I am hoping to eliminate the erroneous string, but if I cannot find out how to do that your recommendation will work. But then I can't just have the MQTT node output JSON. None of these options are really issues though.

I presume you mean you would have to leave it outputting JSON (which is a string) rather than getting it to parse the JSON and output a javascript object. In which case that is correct, you would need the Switch to block the extra messages and then a JSON node to convert the JSON to an object.

Thanks for the tips, Colin.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.