[progress Communities] [progress Openedge Abl] Forum Post: Re: Jsonobject - Jsonarray

  • Thread starter Thread starter Akshay Guleria
  • Start date Start date
Status
Not open for further replies.
A

Akshay Guleria

Guest
First, the json response you have posted in not a valid JSON. You can use any tool like to validate a JSON. Second, below is an example of probably what can help you. Look out for documentation of JsonObject and JsonArray classes and you will find it very easy to understand what else you can do with them. USING Progress.Json.ObjectModel.*. DEF VAR myObject AS JsonObject NO-UNDO. DEF VAR myData AS JsonObject NO-UNDO. DEF VAR myParams AS JsonObject NO-UNDO. DEF VAR lResult AS LONGCHAR NO-UNDO VIEW-AS EDITOR LARGE SIZE 60 BY 16 LABEL "Json Object". DEF VAR lJsArray AS JsonArray NO-UNDO. DEF VAR lAnotherArray AS JsonArray NO-UNDO. /* main json objects/instances */ myObject = NEW JsonObject(). myParams = NEW JsonObject(). /* add data to main json object */ myObject:Add("type", "customer"). myObject:Add("id", 348289). /* add data to params/sub json object */ myParams:Add("first name", "Zingo Singh"). myParams:Add("balance", 430.56). myParams:Add("active", TRUE). myParams:Add("street address", "Kalliotie 11"). myParams:Add("city","Very Shitty"). myParams:Add("zipcode", "07218"). myParams:Add("country", "Finland"). lJsArray = NEW JsonArray(). lJsArray:Add(myParams). lAnotherArray = NEW JsonArray(). lAnotherArray:Add("Array wihtout object"). lJsArray:Add(lAnotherArray). myObject:Add("data", lJsArray). /* write json object to variable for output and param TRUE formats the json for display*/ myObject:WRITE(lResult, TRUE). DISP lResult. Json Object ------------------------------------------------------------ { "type": "customer", "id": 348289, "data": [ { "first name": "Zingo Singh", "balance": 430.56, "active": true, "street address": "Kalliotie 11", "city": "Very Shitty", "zipcode": "07218", "country": "Finland" }, [ "Array wihtout object" ] ] }

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