Choose where you’d like to start

toJSONList

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,

ParameterData typeDescription
<variable>LISTVariable which will contain the converted JSON list.
<json_text>TEXT

The text JSON array which needs to be converted to JSON List.

Note:

  • If the text is not in JSON format, a runtime error will be thrown.

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

Get Started Now

Execute