diff --git a/apax.yml b/apax.yml index fc37064..381c3f5 100644 --- a/apax.yml +++ b/apax.yml @@ -17,11 +17,11 @@ targets: - 'axunit-llvm' # Dependencies devDependencies: - "@ax/sdk": 3.0.18 + "@ax/sdk": 4.0.2 "@simatic-ax/snippetscollection": 0.1.3 dependencies: - "@ax/system-strings": 4.2.3 - "@simatic-ax/conversion": 3.1.2 + "@ax/system-strings": 5.0.12 + "@simatic-ax/conversion": 4.0.1 registries: '@simatic-ax': 'https://npm.pkg.github.com/' # Files which 'apax pack' will include diff --git a/test/Deserializer/TryParse/Test_TryParse.st b/test/Deserializer/TryParse/Test_TryParse.st index 7f8540a..2bdf360 100644 --- a/test/Deserializer/TryParse/Test_TryParse.st +++ b/test/Deserializer/TryParse/Test_TryParse.st @@ -13,6 +13,41 @@ CLASS TryParse buffer : ARRAY[0..999] OF CHAR; END_VAR + {Test} + Method Public Test_TryParse_Value_as_String + VAR + JSON_Entry: STRING := '{ "key1": "nestedkey1"}'; + key: STRING := 'key1'; + len:DINT; + keyFound: BOOL; + value: STRING; + END_VAR + + len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); + deserializer.buffer := REF(buffer); + + keyFound := deserializer.TryParse( key, value); + Equal('nestedkey1', value); + END_Method + + {Test} + Method Public Test_TryParse_Value_as_String2 + VAR + JSON_Entry: STRING := '{"Name": "SIMATIC", data: {plc_type: 1518, OPC_SERVER_ENABLED: true}}'; + key: STRING := 'Name'; + len:DINT; + keyFound: BOOL; + value: STRING; + END_VAR + JSON_Entry:= '{"Name": "SIMATIC", data: {plc_type: 1518, OPC_SERVER_ENABLED: true}}'; + key := 'Name'; + len:= Strings.ToArray.OfCharCount(str := JSON_Entry, arr := buffer); + deserializer.buffer := REF(buffer); + + keyFound := deserializer.TryParse( key, value); + Equal('SIMATIC', value); + END_Method + {Test} Method Public Test_TryParse_String VAR