PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.

Prev | Next | Users Guide | PhantomScript Reference | P1 Systems


Networking

JSONGetValue

Syntax

JSONGetValue <json-var> <member-name>

Description

Get the value of a JSON object's member

Parameters

<json-var>

The JSON object from which the value is to be extracted

<member-name>

The name of the member whose value is desired.

Remarks

The return value of this statement may be a JSON object or a JSON array. The JSONGetType statement can be used to determine the type of the returned value.

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 

JSONAddString jsonObj1 "a-string" "a string value"
JSONAddNumber jsonObj1 "a-number" 42
JSONAddBoolean jsonObj1 "a-boolean" (1 = 1)
JSONAddObject jsonObj1 "an-object" jsonObj1
JSONAddNull jsonObj1 "nothing"
JSONAddArray jsonObj1 "my-array" "1,2,3"


Log "a-string = " & JSONGetValue jsonObj1 "a-string"
Log "a-number = " & JSONGetValue jsonObj1 "a-number"
Log "a-boolean = " & JSONGetValue jsonObj1 "a-boolean"
Log "an-object = " & JSONGetValue jsonObj1 "an-object"
Log "nothing = " & JSONGetValue jsonObj1 "nothing"
Log "my-array = " & JSONGetValue jsonObj1 "my-array"

This script fragment logs the following:

a-string = a string value
a-number = 42
a-boolean = true
an-object = { "a-string": "a string value", "a-number": 42, "a-boolean": true }
nothing = null
my-array = 1,2,3


Prev | Next | Users Guide | PhantomScript Reference | P1 Systems

PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.