import "util/json";
This class wraps the JSON data structure. Normal types (integers, floats, strings, arrays, hashes)
are used for the values so you can access it directly without the convenience of this class too.
However some types don't directly map: null
,
boolean, long and
double. These are represented by special classes with their
constraints.
static function parse(data: Byte[]): JSON
static function parse(data: Byte[], strict: Boolean): JSON
static function parse_string(s: String): JSON
static function parse_string(s: String, strict: Boolean): JSON
function to_bytes(): Byte[]
function to_string(): String
function get(key): JSON
function get(key, default_value): JSON
function opt(key): JSON
get
function that returns a special no value marker
in case the key is not found (or there is some other problem such as type mismatch).
You can check the presence of an actual value by calling the has_value
method. Also the various methods to get values simply return a reasonably safe default
value (such as zeros, empty arrays etc.) when used on the no value marker.
function length(): Integer
function get_keys(): String[]
function has_value(): Boolean
opt
method is an actual value.
function is_null(): Boolean
null
value.
function is_boolean(): Boolean
function is_int(): Boolean
function is_long(): Boolean
function is_float(): Boolean
function is_double(): Boolean
function is_string(): Boolean
function is_array(): Boolean
function is_object(): Boolean
function as_boolean(): Boolean
function as_boolean(default_value: Boolean): Boolean
function as_int(): Integer
function as_int(default_value: Integer): Integer
function as_long(): Long
function as_long(default_value: Integer): Long
function as_float(): Float
function as_float(default_value: Float): Float
function as_double(): Double
function as_double(default_value: Float): Double
function as_string(): String
function as_string(default_value: String): String
function as_array(): JSON[]
function as_object(): JSON[String]
This class represents a JSON's null
value.
static function get(): JSONNull
null
value.
static function is_instance(value): Boolean
null
value.
This class represents a JSON's boolean value.
static function get(value: Boolean): JSONBoolean
static function is_instance(value): Boolean
function to_boolean(): Boolean
function to_string(): String
This class represents a JSON's long value. As JSON has only a double type, this just wraps the exactly representable integer numbers in the range from -9007199254740992 to 9007199254740992 (53 bits).
static function create(value: Long): JSONLong
static function create(lo: Integer, hi: Integer): JSONLong
static function from_int(value: Integer): JSONLong
static function from_string(s: String): JSONLong
static function is_instance(value): Boolean
function to_int(): Integer
function to_long(): Long
function to_string(): String
This class represents a JSON's double value. NaNs and infinities can't be stored.
static function create(value: Double): JSONDouble
static function create(lo: Integer, hi: Integer): JSONDouble
static function from_float(value: Float): JSONDouble
static function from_string(s: String): JSONDouble
static function is_instance(value): Boolean
function to_float(): Float
function to_double(): Double
function to_string(): String