IIoT Library 5_2 JSON_Decode

Hello,
I have been using MQTT_Client previously to do MQTT communication and JSON parsing of any topic payloads and it was all nice and happy, however it means we couldn’t go to newer FW due to the state of that library…. I have switched over to testing the IIoT Library 5_2 and have the MQTT side all sorted, however: Using the IIoT_JSON_Decoder I am having some issues.
I have a topic payload coming from the MQTT_TryConsumeMessage (an array of bytes) of the topic payload of {“Seconds”:”10”} , and if I have that in the anyJsonData of the decoder and enable it it will process without error, but when I go to use the Get_Value method block with an anyJsonKey value of “.Seconds” it will always return an ‘Invalid Key’

If I trigger xGetTree and look on the PLC in /opt/plcnext/custom/JSONValueKey.json I have the following:
.={}
.Seconds=”56”

So I BELIEVE I’m using a valid key……

Note: I CAN parse this bytestream ok using the JSON_V1 library parser, but I want to reduce my exposure to too many different libraries if I can (also I don’t really like how it works needing structures that match the payload…makes it less flexible for my purposes)

Does anyone have a working example of JSON parsing in the IIoT Library V5 that they can share?

We recently switched from the MQTT library directly to the IIoT library, for we discovered, that the former was merely a wrapper around the latter and we needed detailed control and highest possible stability. We also struggled a little w/ the JSONs, but resolved them. If you still need help, message me at t.e.shaw@dahoum.wales and we can have a look.

1 Like