Question parse complex json file with progress code

Bounty

New Member
This is a piece of code to get you started.
Code:
USING Progress.Json.ObjectModel.JsonArray.
USING Progress.Json.ObjectModel.JsonObject.
USING Progress.Json.ObjectModel.JsonDataType.
USING Progress.Json.ObjectModel.ObjectModelParser.

DEFINE VARIABLE JsonParser   AS ObjectModelParser NO-UNDO.
DEFINE VARIABLE ResultObject AS JsonObject        NO-UNDO.
DEFINE VARIABLE FieldNames   AS CHARACTER         NO-UNDO EXTENT.
DEFINE VARIABLE i            AS INTEGER           NO-UNDO.
DEFINE VARIABLE DataType     AS INTEGER           NO-UNDO.

JsonParser = NEW ObjectModelParser().
ResultObject = CAST(JsonParser:ParseFile("C:\Users\Bounty\kontrol-results.json.txt"), JsonObject).

FieldNames = ResultObject:GetNames().
DO i = 1 TO EXTENT(FieldNames):
  DataType = ResultObject:GetType(FieldNames[i]).
  CASE DataType:
    WHEN JsonDataType:NUMBER THEN
      MESSAGE FieldNames[i] "= INTEGER = " ResultObject:GetInteger(FieldNames[i]) VIEW-AS ALERT-BOX.
    WHEN JsonDataTYPE:NULL THEN
      MESSAGE FieldNames[i] "= NULL" VIEW-AS ALERT-BOX.
    WHEN JsonDataType:ARRAY THEN
      MESSAGE FieldNames[i] "= ARRAY" VIEW-AS ALERT-BOX.
  END CASE.
END.
 
Top