vipak/tst/testJsonParser.Mod
2020-06-09 17:57:59 +04:00

28 lines
741 B
Modula-2

MODULE testJsonParser;
IMPORT vpkJsonParser, Out;
VAR
jsonRecord: vpkJsonParser.JsonTypePointer;
testValue: ARRAY 128 OF CHAR;
keyFound: BOOLEAN;
BEGIN
jsonRecord := vpkJsonParser.Create("{'foo': 'bar', 'test': 'test1', 'test2': {'sub': 'dub'}}");
keyFound := jsonRecord.GetTerminal(jsonRecord, "foo", testValue);
IF keyFound THEN
Out.String('found KEY');
Out.String(testValue); Out.Ln;
ELSE
Out.String('Value for the Key is not found'); Out.Ln;
END;
keyFound := jsonRecord.GetTerminal(jsonRecord, "test2.sub", testValue);
IF keyFound THEN
Out.String('found KEY');
Out.String(testValue); Out.Ln;
ELSE
Out.String('Value for the Key is not found'); Out.Ln;
END;
END testJsonParser.