JsonValue¶
Import: import system.json;
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
JsonValue¶
A JSON value: null, boolean, number, string, array, or object. Arrays and objects can contain nested values. Object properties retain insertion order when serialized.
null¶
Creates a JSON null.
from_bool¶
Creates a JSON boolean holding b.
from_double¶
Creates a JSON number holding n. Integral values serialize without a decimal point.
from_int¶
Creates a JSON number holding n; every int is represented exactly.
from_string¶
Creates a JSON string holding s.
array¶
Creates an empty JSON array; add elements with push.
dict¶
Creates an empty JSON object; add properties with value[key] = item. Properties serialize in insertion order.
kind¶
The kind of JSON value, for switch (v.kind()) { case JsonKind.Object: … }.
is_null¶
True if the value is null.
is_array¶
True if the value is an array.
is_object¶
True if the value is an object.
as_bool¶
Returns the value as a bool when this is a JSON boolean.
as_double¶
Returns the value as a double when this is a JSON number.
as_int¶
Returns the value as an integer when this is a JSON number.
as_string¶
Returns the value as a string when this is a JSON string.
as_array¶
Returns the elements when this is an array, otherwise None.
as_map¶
Returns the entries when this is an object, otherwise None.
remove¶
Removes the named object property; returns whether it existed.
contains¶
Returns whether this is an object with a property named key. Always false for arrays and scalars.
get¶
Returns the property named key, or None when this is not an object or the property is absent. Chain as_string, as_int, and similar readers through and_then to read a typed property.
this¶
Returns the property named key. Panics when this is not an object or the property is absent; use get when absence is expected.
this¶
Sets the value for key (objects only).
key_at¶
The object key at index, or None.