Cerberus X Documentation

Class JsonArray

JSON arrays are ordered lists of values in square brackets, e.g. More...

Declarations

Extends
JsonValue This base class provides some fall-back functionality for the specific json value
Properties
Length : Int () Returns length of the array.
Constructors
New ( length:Int ) Creates a new array of the given length.
New ( data:JsonValue[] ) Creates a new array with the given data.
Methods
Get : JsonValue ( index:Int ) Get json value at index.
GetBool : Bool ( index:Int ) Get boolean value at index.
GetData : JsonValue[] () Gets internal array used to contain values.
GetFloat : Float ( index:Int ) Get float value at index.
GetInt : Int ( index:Int ) Get integer value at index.
GetString : String ( index:Int ) Get string value at index.
Set : Void ( index:Int, value:JsonValue ) Set entry at index to specific value.
SetBool : Void ( index:Int, value:Bool ) Set boolean value at index.
SetFloat : Void ( index:Int, value:Float ) Set float value at index.
SetInt : Void ( index:Int, value:Int ) Set integer value at index.
SetString : Void ( index:Int, value:String ) Set string value at index.
Inherited Properties
Type : Int () Indicates the type of the specific JsonValue object.
Inherited Methods
BoolValue : Bool () For a JsonBool, this will return its boolean value.
FloatValue : Float () For a JsonNumber, this will return its numerical value as float.
IntValue : Int () For a JsonNumber, this will return its numerical value as int.
StringValue : String () For a JsonString, this will return its string value.
ToJson : String () Converts value to a JSON string.

Detailed Discussion

JSON arrays are ordered lists of values in square brackets, e.g.

["bar",42]

Note: JsonArrays can't be resized. To achieve that, you have to retrieve the array using GetData, resize the array manually and create a new JsonArray with the resized array as argument.


Properties Documentation

Method Length : Int () Property

Returns length of the array.


Constructors Documentation

Method New ( length:Int )

Creates a new array of the given length.

Method New ( data:JsonValue[] )

Creates a new array with the given data.


Methods Documentation

Method Get : JsonValue ( index:Int )

Get json value at index.

Throws a JsonError if index is out of bounds.

Returns a JsonNull object if element at index is null.

Method GetBool : Bool ( index:Int )

Get boolean value at index.

Throws a JsonError if index is out of bounds or value at index is not a JsonBool.

Method GetData : JsonValue[] ()

Gets internal array used to contain values.

To iterate through the array, use

For Local entry := Eachin json.GetData()
Print entry.ToJson()
End
Method GetFloat : Float ( index:Int )

Get float value at index.

Throws a JsonError if index is out of bounds or value at index is not a JsonNumber.

Method GetInt : Int ( index:Int )

Get integer value at index.

Throws a JsonError if index is out of bounds or value at index is not a JsonNumber.

Method GetString : String ( index:Int )

Get string value at index.

Throws a JsonError if index is out of bounds or value at index is not a JsonString.

Method Set : Void ( index:Int, value:JsonValue )

Set entry at index to specific value.

Throws a JsonError if index is out of bounds.

Method SetBool : Void ( index:Int, value:Bool )

Set boolean value at index.

Throws a JsonError if index is out of bounds.

Method SetFloat : Void ( index:Int, value:Float )

Set float value at index.

Throws a JsonError if index is out of bounds.

Method SetInt : Void ( index:Int, value:Int )

Set integer value at index.

Throws a JsonError if index is out of bounds.

Method SetString : Void ( index:Int, value:String )

Set string value at index.

Throws a JsonError if index is out of bounds.