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

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


Networking

JSONGetType

Syntax

JSONGetType <json-var>

Description

Return the type of a JSON object

Parameters

<json-var>

The JSON object whose type is desired

Remarks

The return value of this statement is one of "Boolean", "Number", "Object", "Array", "String", or "Null". If the object is not recognized, "Null" is returned.

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 = " & JSONGetType jsonObj1 "a-string"
Log "a-number = " & JSONGetType jsonObj1 "a-number"
Log "a-boolean = " & JSONGetType jsonObj1 "a-boolean"
Log "an-object = " & JSONGetType jsonObj1 "an-object"
Log "nothing = " & JSONGetType jsonObj1 "nothing"
Log "my-array = " & JSONGetType jsonObj1 "my-array"

The above script fragment logs the following:

a-string = String
a-number = Number
a-boolean = Boolean
an-object = Object
nothing = null
my-array = Array


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

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