ExtractJSONArray()

Syntax

ExtractJSONArray(JSONValue, Array())
Description
Extract elements from the given JSON value of type #PB_JSON_Array into the specified Array(). The array will be resized to the number of elements contained in the JSON value.

Parameters

JSONValue The JSON value. The value must be of type #PB_JSON_Array.
Array() The array to fill with the JSON elements. The array will be resized to have the same size as the JSON value. Any previous content of the array will be lost.

Return value

None.

Remarks

The extraction is performed recursively if the array has a structure type. If the JSON value contains any elements that do not have the proper type to match the Array(), they will be ignored and the corresponsing array element will be left empty.

If the specified Array() has more than one dimension, the JSON data is expected to be a nested array of arrays to represent the multi-dimensional data. See the below example for more details.

Example

  ParseJSON(0, "[1, 3, 5, 7, 9]")
  
  Dim a(0)
  ExtractJSONArray(JSONValue(0), a())
  
  For i = 0 To ArraySize(a())
    Debug a(i)
  Next i

Example

  ParseJSON(0, "[[0, 1, 2], [3, 4, 5], [6, 7, 8]]")
  
  Dim a(0, 0)
  ExtractJSONArray(JSONValue(0), a())
  
  For x = 0 To 2
    For y = 0 To 2
      Debug a(x, y)
    Next y
  Next x

See Also

ExtractJSONList(), ExtractJSONMap(), ExtractJSONStructure(), InsertJSONArray(), InsertJSONList(), InsertJSONMap(), InsertJSONStructure(), SetJSONArray(), JSONType()

Supported OS

All

<- ExportJSONSize() - Json Index - ExtractJSONList() ->