Try OpenEdge Now
skip to main content
ABL Reference
Class Properties and Methods Reference : GetJsonArray( ) method (JsonObject)
 

GetJsonArray( ) method (JsonObject)

Gets the JsonArray value of the named property.
Return type: Progress.Json.ObjectModel.JsonArray class
Access: PUBLIC
Applies to: Progress.Json.ObjectModel.JsonObject class

Syntax

GetJsonArray( INPUT property-name AS CHARACTER )
property-name
A CHARACTER expression indicates the name of the property value to be retrieved from the JsonObject.
A JsonError is raised if:
*property-name is the empty string (""), or is the Unknown value (?)
*The property does not exist
*The property value is not a JsonArray
The following example demonstrates the functionality of the GetJSonArray( ) method.
The following is a sample JsonObject:
{
  "CustOrder": {
    "CustNum": 1,
    "Name": "Lift Tours",
    "NewCust": false,
    "ttOrder": [
      {"OrderNum": 82, "OrderDate": "2010-09-20"},
      {"OrderNum": 83, "OrderDate": "2010-09-20"}
]
}
}
The following is a code fragment that uses the GetJsonArray( ) method:
DEFINE VARIABLE CustInfo AS LONGCHAR NO-UNDO.
DEFINE VARIABLE myObj AS JsonObject NO-UNDO.
DEFINE VARIABLE myArray AS JsonArray NO-UNDO.
DEFINE VARIABLE myLongchar as LONGCHAR NO-UNDO.

/*
.
. Set CustInfo to JsonObject shown above.
.
*/

myObj = CAST(myParser:Parse(CustInfo), JsonObject).
myArray = myObj:GetJsonObject("CustOrder"):GetJsonArray("ttOrder").
myArray:Write(myLongchar, TRUE).
The following is the resulting myLongchar value:
[
{"OrderNum": 82, "OrderDate": "2010-09-20"},
{"OrderNum": 83, "OrderDate": "2010-09-20"}
]