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): JSONget 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(): Integerfunction get_keys(): String[]function has_value(): Booleanopt method is an actual value.
function is_null(): Booleannull value.
function is_boolean(): Booleanfunction is_int(): Booleanfunction is_long(): Booleanfunction is_float(): Booleanfunction is_double(): Booleanfunction is_string(): Booleanfunction is_array(): Booleanfunction 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(): JSONNullnull value.
static function is_instance(value): Booleannull value.
This class represents a JSON's boolean value.
static function get(value: Boolean): JSONBooleanstatic function is_instance(value): Booleanfunction to_boolean(): Booleanfunction to_string(): StringThis 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): JSONLongstatic function create(lo: Integer, hi: Integer): JSONLongstatic function from_int(value: Integer): JSONLongstatic function from_string(s: String): JSONLongstatic function is_instance(value): Booleanfunction to_int(): Integerfunction to_long(): Longfunction to_string(): StringThis class represents a JSON's double value. NaNs and infinities can't be stored.
static function create(value: Double): JSONDoublestatic function create(lo: Integer, hi: Integer): JSONDoublestatic function from_float(value: Float): JSONDoublestatic function from_string(s: String): JSONDoublestatic function is_instance(value): Booleanfunction to_float(): Floatfunction to_double(): Doublefunction to_string(): String