Syntax
JSONArrayAsList <json-array>Description
Return a JSON array as a PhantomScript list.Parameters
<json-array>
- The JSON array that is to be returned as a list.
Remarks
This statement allows you to extract elements from nested JSON arrays as is 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: ListAsJSONArray, JSONAddArray, JSONAddBoolean, JSONAddNull, JSONAddNumber, JSONAddObject, JSONAddString, JSONArrayAsList, JSONGetKeys, JSONGetType, JSONGetValue, JSONDelete.
Example
! An JSON array of arrays of arrays
j = "{""nested-arrays"":[[[1,2],[3,4]],[[5,6],[7,8]]]}"
level1list = JSONArrayAsList JSONGetValue j "nested-arrays"
level2list = JSONArrayAsList Item1 level1list
level3list = JSONArrayAsList Item1 level2list
MessageBox
Text=level1list & "~n" & level2list & "~n" & level3listThe above script fragment displays these lists in the message box:,
"[ [ 1, 2 ], [ 3, 4 ] ]","[ [ 5, 6 ], [ 7, 8 ] ]" "[ 1, 2 ]","[ 3, 4 ]" 1,2