Activity for JSON parsing and composing library

  • tvm tvm posted a comment on a wiki page

    Check any of your JSONVARs. The Names variable contains an array of the variable name divided by level. For example, if the variable path is Application.Test_SingleVar_PRG.colour, then the array will contain [3] 'Application' [2] 'Test_SingleVar_PRG' [1] 'colour' The ApplicationLevel property should be the array index which contains 'Application', in this case 3. This is all figured out in the JSONVAR.FB_Init method. The other place to check is JSONVAR.VarName, which is the full instance path of...

  • tvm tvm posted a comment on a wiki page

    Correct. In an actual use case I think the compose and parse would happen on different machines.

  • maxkemmeren maxkemmeren modified a comment on a wiki page

    SOLVED SEE REPLIES NOT A BUG, Different thinking approach Hello, There is still a bug within the Json_TO_Struct FB. Within the method MatchAllLevels: The EXIT Statement was in the wrong place within the for loop. As the loop needs to be exited when a match is found. The bug caused the matchalllevels method to always feedback the value false due to the exit statement. When placing the exit after match is set to true the values are parsed into the struct. --------------------------------------OLD-----------------------------------------------------------...

  • maxkemmeren maxkemmeren posted a comment on a wiki page

    I Found my thinking mistake. You made it that you can onlyh parse from and to a struct of the same instance name. In my example I parse a writing struct and than parse it back into a reading struct of the same type. But as the writing and reading struct have different instance names this match all levels does not become true making the reading struct empty. So parsing to and from 1 struct instance will work.

  • maxkemmeren maxkemmeren posted a comment on a wiki page

    sFileContentsWrite_Struct : ST_TEST; sFileContentsWrite_Struct_Json : ST_TEST_Json; sFileContentsRead_Struct_Json : ST_TEST_Json; sFileContentsRead_Struct : ST_TEST; sFileContentsWrite_Struct_Json.fReal.Number := sFileContentsWrite_Struct.fReal; sFileContentsWrite_Struct_Json.nInteger.Integer := sFileContentsWrite_Struct.nInteger; sFileContentsWrite_Struct_Json.sText.CharString := sFileContentsWrite_Struct.sText; sFileContentsWrite_Struct_Json.fLreal.Number :=sFileContentsWrite_Struct.fLreal; s_fbJsonParser(...

  • tvm tvm posted a comment on a wiki page

    If you can post an example I can test it here.

  • maxkemmeren maxkemmeren posted a comment on a wiki page

    OKay but then there must be another error, as after the change the functionblock read all the values into my local struct. Without the fix my local struct stayed empty all the time.

  • tvm tvm posted a comment on a wiki page

    The EXIT is in the correct place in the original, this is not a bug. The loop returns FALSE and exits on the first occurrence of a mismatch. If there are any mismatches, there is no point in evaluating the rest of the array. All levels must match for this method to return TRUE.

  • maxkemmeren maxkemmeren posted a comment on a wiki page

    Hello, There is still a bug within the Json_TO_Struct FB. Within the method MatchAllLevels: The EXIT Statement was in the wrong place within the for loop. As the loop needs to be exited when a match is found. The bug caused the matchalllevels method to always feedback the value false due to the exit statement. When placing the exit after match is set to true the values are parsed into the struct. --------------------------------------OLD-----------------------------------------------------------...

  • uspenskiyan uspenskiyan posted a comment on a wiki page

    Hello. I have an error in JSON_TO_STRUCT when trying to get JSON from string: 'Check application name in GPL_JSON.APPLICATION_NAME'. But I didn't change my application name, it's still "Application". What's wrong?

  • tvm tvm modified a wiki page

    Home

  • tvm tvm modified a wiki page

    Home

  • tvm tvm modified a wiki page

    Home

  • manuknecht manuknecht posted a comment on a wiki page

    Thanks a lot for the update! So my project worked with the old version of the library for you? That is very strange. Need to check it from my side then.

  • tvm tvm modified a wiki page

    Home

  • tvm tvm posted a comment on a wiki page

    I've released v 1.0.0.15 (link above). I tested your project as well as several of mine, with various different orders of the variables and it's working for me. The code on line 100 was correct, as far as how the FOR loop/EXIT worked, but I refactored some of that to make it easier to understand.

  • tvm tvm modified a wiki page

    Home

  • manuknecht manuknecht modified a comment on a wiki page

    I'll attach a project to this message. I am using the HTTPClient library to read a JSON string through a HTTP request. I left you a sample string that I want to parse in the code to demonstrate the issue. You can see that the key-value pairs do not match up between the string and the JSON struct. Hope that helps.

  • manuknecht manuknecht posted a comment on a wiki page

    I'll attach a project to this message. I am using the HTTPClient library to read a JSON string through a HTTP request. I left you a sample string in the code to demonstrate the issue. Hope that helps.

  • tvm tvm posted a comment on a wiki page

    I think I have reproduced something like this, but it would be helpful if you can provide a test program, or at least a JSON string that demonstrates it.

  • manuknecht manuknecht posted a comment on a wiki page

    If you will tackle it again, here's another issue I discovered. The JSON string I want to parse contains some nested arrays and objects. It came to my attention, that proper parsing only works when the key-value pairs on the lowest level (inside arrays) are sorted alphabetically. Otherwise, the values can be assigned to the wrong keys. I didn't check the code further to find what causes this, but maybe you will have an idea? Otherwise it seems to do what it does, so thanks a lot for sharing!

  • bnewman bnewman posted a comment on a wiki page

    awesome! thank you sir.

  • tvm tvm modified a comment on a wiki page

    @bnewman as far as I'm concerned, it's released under the terms of "it's on the internet so people can do whatever the heck they want with it". I think I had to pick a license when I put it on here, but I don't actually know anything about GPL, nor do I care. Use it, modify it, copy it, put it in your own projects, contribute to it, credit me. Or not. Whatever you like. I just changed the licensing to both MIT and Unlicense. I honestly don't know the difference, but I hope that makes it easier for...

  • tvm tvm posted a comment on a wiki page

    I haven't had a lot of time to do anything with this for several months, but thanks for the input. It does look like a bug, I'll try to take a closer look at it next week.

  • tvm tvm posted a comment on a wiki page

    @bnewman as far as I'm concerned, it's released under the terms of "it's on the internet so people can do whatever the heck they want with it". I think I had to pick a license when I put it on here, but I don't actually know anything about GPL, nor do I care. Use it, modify it, copy it, put it in your own projects, contribute to it, credit me. Or not. Whatever you like.

  • bnewman bnewman posted a comment on a wiki page

    Will you please rerelease this under MIT or MPL2? GPL is a cancer.

  • manuknecht manuknecht modified a comment on a wiki page

    I am aware that this thread is three years old, but I ran into the same issue and could not resolve it. Does anyone know what can cause this? Thanks in advance! Edit: After some more tinkering, I found the issue preventing proper parsing of the JSON string. For this the library function JSON_TO_STRUCT (FB) has to be adjusted from row 100. The original implementation is as follows: //Match name and array index. Array index will be 0 if the current name:value is not part of an array IF MATCH_NAMES(JSONVars^[jsonvarindex].Names[nameindex],...

  • manuknecht manuknecht posted a comment on a wiki page

    I am aware that this thread is three years old, but I ran into the same issue and could not resolve it. Does anyone know what can cause this? Thanks in advance!

  • tvm tvm modified a wiki page

    Home

  • tvm tvm modified a wiki page

    Home

  • tvm tvm modified a wiki page

    Home

  • tvm tvm modified a wiki page

    Home

  • kamilp-2097 kamilp-2097 posted a comment on a wiki page

    Hello, have you managed to solve this case? I am struggling with the same issue. Thanks.

  • tvm tvm posted a comment on a wiki page

    I'll see if I can find some time to test this out.

  • tvm tvm posted a comment on a wiki page

    good catch, I'll add that to future versions

  • tvm tvm posted a comment on a wiki page

    Hi, I haven't had time to test it, but have you tried recordset :ARRAY [1..1] OF strPGTdataSet;

  • jumax jumax posted a comment on a wiki page

    Hello, I have a problem parsing a JSON string and I need help. The string I receive: '[{"device_id":"1","pgt_id":"2","usertag":"3","hgl":"4","ls":"5","rs":"6","erg":"7"}]' The struct I devined: TYPE strPGTdataSet: STRUCT device_id :JSONVAR; pgt_id :JSONVAR; usertag :JSONVAR; hgl :JSONVAR; ls :JSONVAR; rs :JSONVAR; erg :JSONVAR; END_STRUCT END_TYPE The FB I call: ParseJSON( Execute:=xParseJSON, JSONString:= ADR(hTTPClient_0.httpResult.sContent), JSONStringSize:= SIZEOF(hTTPClient_0.httpResult.sContent),...

  • schwi schwi posted a comment on a wiki page

    Hi, you should add (GPL_JSON.MAX_VALUE_SIZE) on this string. Because if bigger value sizes it runs into faulty parse. TYPE JSONNAMEVALUE : STRUCT Value: STRING(GPL_JSON.MAX_VALUE_SIZE); //value of the object at this level END_STRUCT END_TYPE Greetings

  • nothinrandom nothinrandom modified a comment on a wiki page

    Hello Guys, I believe there's an issue with nested structs on all verions. For example: TYPE stDebugJson : STRUCT timestamp : JSONVAR; messageType : JSONVAR; //message : JSONVAR; //works fine with setting MaxLevel to 1 message : stDebugMessageDetails; // missing end bracket END_STRUCT END_TYPE stDebugMessageDetails is just another type: TYPE stDebugMessageDetails : STRUCT message : JSONVAR; END_STRUCT END_TYPE The output looks like: {"debugMessageJson":{"timestamp":"2020-03-06T23:27:22.966Z","me...

  • nothinrandom nothinrandom posted a comment on a wiki page

    Hello Guys, Thanks for releasing this. Using the latest version 1.0.0.8, I noticed that it also outputs extra entries "loggerInstance" and "debugMessageJson". How do I remove this as my message should only look like: { "timestamp": "2020-03-06T22:57:48.902Z", "messageType": "DEBUG", "message": "this is a test for the logger debug code" } Version 1.0.0.8 produces: { "loggerInstance": { "debugMessageJson": { "timestamp": "2020-03-06T22:57:48.902Z", "messageType": "DEBUG", "message": "this is a test...

  • tvm tvm modified a wiki page

    Home

  • tvm tvm modified a wiki page

    Home

  • tvm tvm committed [r8]

    version 1.0.0.7

  • svenjotec svenjotec modified a comment on a wiki page

    It's cleared.

  • svenjotec svenjotec modified a comment on a wiki page

  • svenjotec svenjotec posted a comment on a wiki page

    One Question. It is possible to create the following JSON String. I don't kwow, how it works with the example. The problem is the array of different kinds of objects. With 3S-library it is possible. And it is a valid JSON-String. { "requestId": 1, "name" : "getPosition", "params" : {"node":10000220}, {"units": {"length":"mm","angle":"deg"}}, {"origin":1002} } Thanks a lot.

  • Admin Admin committed [r7]

    Added some fixes for special formatting in the JSON file:

  • Admin Admin committed [r6]

    Merged changes from CODESYS SVN back to library file and built the package

  • tvm tvm committed [r5]

    version 1.0.0.2

  • codesys.com codesys.com modified a wiki page

    Home

  • codesys.com codesys.com committed [r4]

    Added package

  • codesys.com codesys.com committed [r3]

    Moved CODESYS lib two levels deeper to make space for the the package and potentially more projects or files.

  • tvm tvm committed [r2]

  • tvm tvm committed [r1]

    Add initial directories

1