READ JSON - - Forum - OpenEdge Development - Progress Community
 Forum

READ JSON -

This question is not answered

HI,

I need to read JSON that does not contain an object name or array.

i.e.

"invoice_info": {

"id": "6376705",
"amount": "1.00",
"invoice_number": "111",
"last_payment_date": "28/05/2018",
"subscriber_no": "111",
"company_no": null,
"query_id": null,
"owner_name_masked": "MU*** MU***",
"foundation_id": 143 

}

I can't see any example in OE 11.7.

Any help is appreciated.

Thx.

All Replies
  • I don't think OpenEdge supports that kind of JSON. You need to add a pair of { } around the string before parsing it.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • I don't think OpenEdge supports that kind of JSON. You need to add a pair of { } around the string before parsing it.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • OpenEdge doesn't support this kind of JSON:

    documentation.progress.com/.../index.html

  • This is not valid JSON... See https://jsonlint.com/ for example.

  • This is not valid JSON... See https://jsonlint.com/ for example.

  • Thanks your reply. I checked JSON is not correct. Below correct, I think, JSON.

    {

    "count": 1,

    "next": null,

    "previous": null,

    "results": [{

    "id": "6376703",

    "status": "open",

    "amount": "1.00",

    "payment_time": null,

    "invoice_info": {

    "id": "6376705",

    "amount": "1.00",

    "invoice_number": "111",

    "last_payment_date": "28/05/2018",

    "subscriber_no": "111",

    "company_no": null,

    "query_id": null,

    "owner_name_masked": "MU*** MU***",

    "foundation_id": 143

    }

    }]

    }

    My question is for "invoice_info". With this example

    def var joObj2 as JsonObject.

    i=oJsonArray:LENGTH.

    joObj2 = oJsonArray:GetJsonObject(i).

    def var charstring as char.

    charstring = string(joObj2:GetJsonText("invoice_info")).

    message charstring.

    charstring contains:

                           "id": "6376705",

    "amount": "1.00",

    "invoice_number": "111",

    "last_payment_date": "28/05/2018",

    "subscriber_no": "111",

    "company_no": null,

    "query_id": null,

    "owner_name_masked": "MU*** MU***",

    "foundation_id": 143"

    How I can READ separately as if it were an array.

    Thanks.

    G.

  • invoice_info is a JsonObject. You cannot walk it like a JsonArray.
     
    To dynamically access the properties of a JsonObject, use the GetNames() property of the JsonObject to receive the property names as an ABL Character Array.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.