Hello,
I am trying to implement a FB to make JSON formatted WSTRING type message using JSON Utilities 1.9.0.0 included in the IIoT library.
In my case, I want to set some objects or arrays and set values to them later.
But when I wrote as the sample below,
// init builderbuilder(pJsonData:=pJsonData,diRootObj=>diRootObj);// set the 1st key to rootdiKey1:=builder.SetKeyWithArray(wsKey:="key1",diParentIndex:=diRootObj,eError=>eError);// set a value to the 1st keywsValue:="value01";builder.SetValue(Value:=wsValue,diParentIndex:=diKey1,eError=>eError);// set the 2nd key to rootdiKey2:=builder.SetKeyWithArray(wsKey:="key2",diParentIndex:=diRootObj,eError=>eError);// set a value to the 2nd keywsValue:="value02";builder.SetValue(Value:=wsValue,diParentIndex:=diKey2,eError=>eError);// set a value to the 1st key againwsValue:="value03";builder.SetValue(Value:=wsValue,diParentIndex:=diKey1,eError=>eError);// set a value to the 2nd key againwsValue:="value04";builder.SetValue(Value:=wsValue,diParentIndex:=diKey2,eError=>eError);// write build resultwriter(xExecute:=TRUE,pwData:=ADR(wsResult),udiSize:=SIZEOF(wsResult),xAsyncMode:=FALSE,jsonData:=pJsonData^);
Hey there! I am currently running into the exact same issue.
The JsonData object has all inexes & parent indexes in the way I expect, everything is correctly "linked".
It purely seems that the writer is incorrectly parsing said JsonData, not based on parent & child index, but on something else that breaks it and puts things at the root, instead of the specified parent index.
Did you ever manage to find a solution, or another way of achieving your JSON composing?
I'm currently working on Codesys V3.5 SP19 Patch 7 with IIOT Libraries SL 1.13.0.0, specifically JSON Utilities SL 1.13.0.0 (to send requests to APIs with JSON bodies using Web Client SL 1.13.0.0).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am trying to implement a FB to make JSON formatted WSTRING type message using JSON Utilities 1.9.0.0 included in the IIoT library.
In my case, I want to set some objects or arrays and set values to them later.
But when I wrote as the sample below,
the result was:
while my expection was:
Inspecting pJsonData^, JSONData itself seems to be ok, so I believe the issue is something caused by the writer FB.
Does anyone know how to fix it?
Thanks,
Hey there! I am currently running into the exact same issue.
The JsonData object has all inexes & parent indexes in the way I expect, everything is correctly "linked".
It purely seems that the writer is incorrectly parsing said JsonData, not based on parent & child index, but on something else that breaks it and puts things at the root, instead of the specified parent index.
Did you ever manage to find a solution, or another way of achieving your JSON composing?
I'm currently working on Codesys V3.5 SP19 Patch 7 with IIOT Libraries SL 1.13.0.0, specifically JSON Utilities SL 1.13.0.0 (to send requests to APIs with JSON bodies using Web Client SL 1.13.0.0).
See : https://forge.codesys.com/forge/talk/Engineering/thread/9afc7c8bad/#711c