toJSONList
Table of Contents
Overview
The toJSONList function takes a text JSON array as an argument, and returns it as a list.
Return Type
- LIST
Syntax
<variable> = <json_text>.toJSONList();
where,
Parameter | Data type | Description |
<variable> | LIST | Variable which will contain the converted JSON list. |
<json_text> | TEXT | The text JSON array which needs to be converted to JSON List. Note:
|
Examples
The example below retrieves a value inside Collection from a JSON.
json_text = "{Name:'Lia Shelton', OrderNo:[343,443,577]}"; orderNo = json_text.getJSON("OrderNo"); info orderNo.toJSONList(); // Returns 343,443,577
The example below retrieves IDs of all employees in the form of a Collection from a JSON.
response = "{\"data\" : [{\"id\":1, \"firstname\":\"John\", \"lastName\":\"Day\"}, {\"id\":2, \"firstname\":\"Patricia\",\"lastname\":\"Boyle\"}]}"; data = response.getJSON("data"); json_list = data.toJSONList(); id_list = List(); for each item in json_list { id_list.add(item.getJSON("id")); } info id_list; // Returns 1,2