12/29/2023 10:43 AM | |
Posts: 6 Rating: (1) |
when using Library LStream and example project for TIA Portal V16 (2,7 MB)(SHA-256) with TIA16, using "LStream_JsonSerializer" there are a bug that if the type of the fist value is 'string' in the input output parameter tree[0], then the jsonByteArray will not show the value but with null, something like this: "Key": "", this the third party software I can find the string missing: then I found maybe the program has a bug to CONCAT the first string's value between two "#QUTATIONMARK"s in line No.215 of "LStream_JsonSerializer", when I modified the program like below it works well: //zorro 2023/12/29 #statInfoToWrite := CONCAT(IN1 := CHAR_TO_STRING(#QUTATIONMARK), IN2 := #tree[#statIndexTreeArray].key, IN3 := CHAR_TO_STRING(#QUTATIONMARK), IN4 := CHAR_TO_STRING(#COLON), IN5 := CHAR_TO_STRING(#QUTATIONMARK),IN6 := #tree[#statIndexTreeArray].value, IN7 := CHAR_TO_STRING(#QUTATIONMARK));
|
Last edited by: @zorro at: 12/29/2023 11:00:46 |
|
This contribution was helpful to2 thankful Users |
12/30/2023 9:20 AM | |
Joined: 3/30/2020 Last visit: 11/19/2024 Posts: 4968 Rating: (1012) |
Thank you for your very helpful report. Please could you do me one more favour?.. Thanks in advance for your co-operation. |
Activities of this user is voluntary. There is no obligation or liability placed on this user. Though optional, your 'please' and 'thank you' is highly valued. |
|
This contribution was helpful to2 thankful Users |
1/2/2024 1:49 PM | |
Joined: 7/7/2010 Last visit: 11/19/2024 Posts: 15406 Rating: (2446)
|
Does the LStream documentation describe how to parse a Siemens String datatype into json, with the max length, actual length, and then character array with size set to max length? If not, then you need to convert the "string" to a char array of the exact length, with perhaps a null termination if json expects that for json "strings".
|
science guy |
|
This contribution was helpful to1 thankful Users |
1/2/2024 2:53 PM | |
Posts: 6 Rating: (1) |
According to the documentation of "LStream_typeElement", for the defination of "type": When the UDT is used in the context of a JSON structure, 0 represents an object, 1 represents an array, 2 represents a string, 3 represents a number und 4 represents a Bool looks we can use String datatype directly inner the "tree" parameter. For instance, the problem is in the "tree" DB: "dbJson", we have an array and each item's type is "LStream_typeElement": the first element "dbJson[0]" and the second "dbJson[1] has the same "type"=2 represents a string, same "depth"=0 and "closingElement"=false, the only difference are the content of the "key" and "value", then after parsing this "dbJson" via "LStream_JsonSerializer", the second element's value is correct string("Module2") in the result "JsonByteArray", but the first one's value is "null" , it should be "Line1":
|
Last edited by: @zorro at: 01/02/2024 14:55:18 |
|
1/2/2024 3:02 PM | |
Joined: 7/7/2010 Last visit: 11/19/2024 Posts: 15406 Rating: (2446)
|
Once your S7 String is built and ready to move to json, are you using the LStream_WriteOutString Function to do that?
|
science guy |
|
1/2/2024 3:25 PM | |
Posts: 6 Rating: (1) |
No, I didn't use "LStream_WriteOutString", I just fill the value of the element like this : tree[0].value := "LIne1"; ... tree[1].value := "Module2"; then call: "LStream_JsonSerializer"
|
Follow us on