Syntax
JSONAddObject <json-var> <member-name> <json-var2>Parameters
<json-var>
- A variable containing the JSON object to which the object is to be added.
<member-name>
- The name of the member in the JSON object that is to contain the added object.
<json-var2>
- A literal JSON object string or a variable containing a JSON object.
Remarks
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
Local jsonObj1
JSONAddNumber jsonObj1 "a-number" 42
JSONAddBoolean jsonObj1 "a-boolean" (1 = 1)
JSONAddObject jsonObj1 "an-object" jsonObj1
JSONAddNull jsonObj1 "nothing"
Local jsonObj2
JSONAddString jsonObj2 "string2" "another string value"
JSONAddString jsonObj2 "string3" "yet another string value"
Log jsonObj2
JSONAddObject jsonObj1 "object-2" jsonObj2
MessageBox Text=jsonObj1The above script fragment displays this JSON object in the message box:
{ "a-number": 42, "a-boolean": true, "an-object": { "a-number": 42, "a-boolean": true }, "nothing": null, "object-2": { "string2": "another string value", "string3": "yet another string value" } }.