GetJsonArray( ) method (JsonArray)

Gets the JsonArray value of one or more elements as a JsonArray or array of JsonArray.

Return type: Progress.Json.ObjectModel.JsonArray class

Access: PUBLIC

Applies to: Progress.Json.ObjectModel.JsonArray class

Syntax

GetJsonArray( INPUT index AS INTEGER )

GetJsonArray( INPUT index AS INTEGER,
                     INPUT count AS INTEGER )

When this method is called with one parameter, the value of a single element is returned. Using two parameters directs the AVM to return an ABL array consisting of count elements.

index
An INTEGER identifying the value of the element to be returned. Indexing into JsonArrays is 1-based.
count
An INTEGER specifying the number of elements, starting with the element at index, to be returned in the ABL array.

A JsonError is raised if:

The following example demonstrates the functionality of the GetJSonArray( ) method.

The following is a sample JsonArray:

[
    {"OrderNum": 82, "OrderDate": "2010-09-20"},
    {"OrderNum": 83, "OrderDate": "2010-09-20"},
    ["Q1", "Q3", 15, 1980, null, 2010]
]

The following code fragment demonstrates the use of GetJsonArray( ) method:

DEFINE VARIABLE OrderInfo AS LONGCHAR NO-UNDO.
DEFINE VARIABLE OrderArray AS JsonArray NO-UNDO.
DEFINE VARIABLE SummaryArray AS JsonArray NO-UNDO.
DEFINE VARIABLE myLongchar as LONGCHAR NO-UNDO.

/*
 .
 . Set OrderInfo to the JsonArray shown above.
 .
 */

OrderArray = CAST(myParser:Parse(OrderInfo), JsonArray).
SummaryArray = OrderArray:GetJsonArray(3).
SummaryArray:Write(myLongchar, TRUE).

The following is the resulting myLongchar value:

["Q1", "Q3", 15, 1980, null, 2010]