util.JSONArray.get() returns a value of a member of the JSON array.
Syntax:
util.JSONArray.get(index)
Parameters:
index |
an index of the member of the specified JSON array |
Receiving variable can be of STRING, util.JSONObject, or util.JSONArray types.
Usage and examples:
util.JSONArray.get() returns a value, a JSON object or an element of the JSON object that corresponds to the index passed as the method's parameter.
If the element identified by the name is a simple value, the method will return a string (see example #1 ↓).
If the element is structured or a part of the structured data, the method will return a util.JSONObject instance (thus, the returned instance must be assigned to a variable of the util.JSONObject type).
If the element is a list of values or a value from this list, the method will return a util.JSONArray instance (thus, the returned instance must be assigned to a variable of the util.JSONArray type).
(with a simple value) |
MAIN DEFINE json_arr util.JSONArray LET json_arr = util.JSONArray.parse('[123,"abc"]') DISPLAY json_arr.get(1) DISPLAY json_arr.get(2) CALL fgl_getkey() END MAIN
|
obtained results |
|
Array members can be set with the util.JSONArray.put() method.
Example programs:
CVS server: client.querix.com
CVS repository: /lycia_doc_examples
User: client
Project: auxiliary_features/json
Program: util_JSONArray_get
Related articles: