[Stackoverflow] [Progress OpenEdge ABL] Add JSONARRAY in an OPENEDGE JSONOBJECT,PROGRESS-4GL

  • Thread starter Thread starter Luis Martinez
  • Start date Start date
Status
Not open for further replies.
L

Luis Martinez

Guest
I am trying to recreate this JSON but in my code the array leaves it out of the JSON object. I have not seen it in the documentation of how to keep it inside. This is my code in it's current state and how it exits. I've also added how I want it to look.

How I want it to look.
{
"data": [
{
"external_id": "AlphaNumeric",
"external_branch_id": "AlphaNumeric",
"name": "Super Awesome Guy",
"cellphone": "String_int",
"gender": "(m/f only)",
"autosuggest": int,
"campaigns": [
{
"name": "Super Awesome Campaign"
}
]
}
]
}

My code:

Code:
/* Create new JsonObjects */
oJson     = NEW JsonObject().
oJsonData = NEW JsonObject().

aJson1stTable = NEW JsonArray().
aJson2ndTable = NEW JsonArray().
//oJson:READ(TEMP-TABLE data:HANDLE).

oJson:Add("data", aJson1stTable).
aJson1stTable:READ(TEMP-TABLE data:HANDLE).
oJson:Add("campaigns", aJson2ndTable).
aJson2ndTable:READ(TEMP-TABLE campaigns:HANDLE).
//oJson:READ(TEMP-TABLE campaigns:HANDLE).

/* Write the JSON string to a character variable */ 
oJson:Write(jSon_string,TRUE).

How are you getting it out:

Code:
{
  "data": [
    {
      "external_id": "97816",
      "external_branch_id": "1",
      "external_user_id": null,
      "name": "AIDE RODRIGUEZ MAR",
      "force_delete_rs": false,
      "rs": null,
      "cellphone": "1111111111",
      "telephone": "5555102609",
      "email": "lizmar056@gmail.com",
      "customer_category": null,
      "gender": "M",
      "birthday": "2001-11-09",
      "autosuggest": false,
      "force_delete_addresses": false
    }
  ],
  "campaigns": [
    {
      "name": "Bono Activo"
    }
  ]
}

If you can tell me how I should do it and where I was wrong.

Continue reading...
 
Status
Not open for further replies.
Back
Top