util.JSONArray.parse()

 

util.JSONArray.parse() parses a JSON string into a new JSON array.

 

Syntax:

 

util.JSONArray.parse(source)

 

Parameters:

 

source

a JSON string from which the JSON array is created

 

Usage and examples:

 

util.JSONObject.parse() scans the JSON data string passed as the parameter, separates the pieces of the string that correspond to the structure of a JSON array, and creates a new JSON array.

 

An object newly created by util.JSONArray.parse() must be assigned to a variable of the util.JSONArray data type.

 

example code #1

MAIN

  DEFINE json_arr util.JSONArray

    LET json_arr = util.JSONArray.parse("[1, 2, 3, 4, 5]")

    DISPLAY json_arr.toString()

  CALL fgl_getkey()

END MAIN

 

obtained results #1

 

example code #2

MAIN

  DEFINE json_arr util.JSONArray

    LET json_arr = util.JSONArray.parse("[1,2,3,4,5]")

    DISPLAY json_arr.toString()

    LET json_arr = util.JSONArray.parse("[1.1,12.21,123.321]")

    DISPLAY json_arr.toString()

    

    LET json_arr = util.JSONArray.parse('["abc","aabbcc","aaabbbccc"]')

    DISPLAY json_arr.toString()

    

    LET json_arr = util.JSONArray.parse("[true, false, null]")

    DISPLAY json_arr.toString()

        

  CALL fgl_getkey()

END MAIN

 

obtained results #2

 

If the JSON string is not properly formatted, the -8109 error - Verify the input string passed to the JSON parsing function. See the description for more details - is returned to the user.

 

 

Example programs:

CVS server: client.querix.com

CVS repository: /lycia_doc_examples

User: client

Project: auxiliary_features/json

Program: util_JSONArray_parse

 

Related articles:

util.JSONArray.create()

util.JSONArray.fromFGL()