Syntax
ListAsJSONArray <list>Description
Return a PhantomScript list as a JSON array.Parameters
<list>
- The list that is to be returned as a JSON array. This list may contain JSON objects as well as normal PhantomScript values.
Remarks
This statement allows you to construct nested JSON array structures such as that shown in the example.JSON (JavaScript Object Notation) is a lightweight data format based on the object notation of the JavaScript language. It does not require JavaScript to read or write; it is easy to parse by any language and libraries and tools exist in many languages to handle JSON.
Here is the entire list of PhantomScript JSON statements: JSONAddArray, JSONAddBoolean, JSONAddNull, JSONAddNumber, JSONAddObject, JSONAddString, ListAsJSONArray, JSONGetKeys, JSONGetType, JSONGetValue, JSONDelete.
Example
Local list1 = "1,2"
Local list2 = "3,4"
Local list3 = "5,6"
Local list4 = "7,8"
Local list12
AppendItem list12 ListAsJSONArray list1
AppendItem list12 ListAsJSONArray list2
Local list34
AppendItem list34 ListAsJSONArray list3
AppendItem list34 ListAsJSONArray list4
Local list1234
AppendItem list1234 ListAsJSONArray list12
AppendItem list1234 ListAsJSONArray list34
MessageBox Text=ListAsJSONArray List1234The above script fragment displays this JSON array in the message box:
[ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ]This is a JSON array with two elements, each of which is in turn a JSON array with two elements, each of which is also a JSON array with two elements.