util.JSONArray.get

Returns the value of a JSON array element.

Syntax

util.JSONArray.get(
   index INTEGER )
  RETURNS result-type
  1. index is the index of the element in the JSON array object.
  2. result-type can be a simple type, a util.JSONObject or a util.JSONArray object reference.

Usage

The get() method returns the value or JSON object corresponding to the element at the given position.

The index corresponding to the first element is 1.

If no element exists at the given index, the method returns NULL.

If the element identified by the name is a simple value, the method returns a string. If the element is structured, the method returns a util.JSONObject instance and the returned object must be assigned to a program variable defined with the util.JSONObject type. If the element is a list of values, the method util.JSONArray instance and the returned object must be assigned to a program variable defined with the util.JSONArray type.

A name/value pair can be set with the put() method.

Example

IMPORT util
MAIN
    DEFINE arr util.JSONArray
    LET arr = util.JSONArray.parse('[123,"abc",null]')
    DISPLAY arr.get(2) -- abc
END MAIN