fbarresi / BeckhoffJsonReadWriter

Read and write json file from a Beckhoff PLC
MIT License
23 stars 4 forks source link

Getting the Ouptut #2

Closed JaMa-95 closed 2 years ago

JaMa-95 commented 2 years ago

Hello Frederico, could you please help me with using your library.

I am using the following json:

{
  "name":"John",
  "age":30, 
  "car":"blue"
}

My MAIN looks like this:

VAR
    parser : JsonParser;
    Json_Content : STRING(255);
    a : STRING;
        json : json_st;
END_VAR
parser(
    Execute:=FALSE , 
    File:= 'C:/temp/json_test.json', 
    ParseMethod:= 'Read' , // or even 'Write'
    Content:= 'json',
    HasError=> , 
    ErrorId=> );
a := json.name;

And lastly this is my struct:

TYPE json_st :
STRUCT
    name : STRING;
    age : INT;
    car : STRING;
END_STRUCT
END_TYP

The Code is getting executed so far, but the Struct Variables do not get updated with the Json Variables. I tried lots of different things but do not see my problem. Could you please help me?

Thanks a lot

fbarresi commented 2 years ago

Dear JaMa,

Please apologize my delayed answer. Can I still help you with an example?

Best regards, Federico

fbarresi commented 2 years ago

I tested your example: it sadly doesn't work because of the parsing method your are using. ´Read´ means in the plc: you read a variable and write it into json ´Write´ means in the plc: you read a json and write it into a plc

I will enhance this misunderstanding naming rules with an update. Thank you for make me notice this problem and for using my software.

Best regards, Federico

fbarresi commented 2 years ago

Closed due to inactivity.

adisita commented 2 years ago

Hi Frederico, Was trying to use the library ( locally on my laptop) ( both read and write) but I can't get it to work :( . The code runs but doesn't read/write to/from a JSON file. and I'm not getting any errors either. is there anything that I miss ? I appreciate any help