Handling JSon messages in Progress

Posted by noekleb on 19-Feb-2018 13:31

Is it possible to load the message below into a progress dataset?

/* ------------------------------------------------------------ */

{
"Message": {
"Id": "id-0",
"Company": "NR",
"Prodnr": {
"Beskrivelse": "OH medarbeider",
"Koststed": {
"Beskrivelse": "SDKP Kompetanse",
"Id": 8131
},
"Sendear": 2018,
"Gyldighet": {
"StartPeriode": 201609,
"SluttPeriode": 209912
},
"Id": "APUS110166",
"Operation": "UPDATE",
"Lokasjon": 700,
"Sperret": false
}
}
}

Posted by Robin Brown on 19-Feb-2018 14:41

No, it is not possible for the JSON string above to be deserialized into a dataset.  In the OpenEdge ABL, a  dataset is serialized as a JSON object, containing a sequence of JSON arrays representing the member temp-tables.  Each temp-table JSON array consist of a sequence of JSON objects containing field data for each row.

{"myDataset:{

    "myTT1":[

        {row1 field values},

        {row2 field values},

        ..

    ],

    "myTT2":[

     ...

   ]

}

}

All Replies

Posted by Robin Brown on 19-Feb-2018 14:41

No, it is not possible for the JSON string above to be deserialized into a dataset.  In the OpenEdge ABL, a  dataset is serialized as a JSON object, containing a sequence of JSON arrays representing the member temp-tables.  Each temp-table JSON array consist of a sequence of JSON objects containing field data for each row.

{"myDataset:{

    "myTT1":[

        {row1 field values},

        {row2 field values},

        ..

    ],

    "myTT2":[

     ...

   ]

}

}

Posted by Torben on 20-Feb-2018 03:52

You can maybe write method to modify the JsonObject to something that matches DataSet load format!

To get a sample of what to match, write dataset with data to Json ;)

Posted by gdb390 on 20-Feb-2018 03:59

Work with the ObjectModelParser !

/* cast request to json object, request = your message */

myParser = new Progress.Json.ObjectModel.ObjectModelParser().

objJSON = cast(myParser:Parse(ipcRequest), Progress.Json.ObjectModel.JsonObject).

use GetCharacter, GetInt, GetArray to do your thing !

e.g.

vcTechnieker = objJSON:GetCharacter("technieker":u) no-error.

Posted by Peter Judge on 21-Feb-2018 06:30

You can also call the READ-JSON() buffer/datset method  with “JsonObject” and a JsonObject – so if the properties on the JSON objects match the field names or serialize-names then extract the  JSON and call that.

This thread is closed