serialize
Boxed
object Boxed
Utility object to manage deserialized data from, for example, decoded JSON
init
static fun init(any data) > Boxed !> CircularReference, NotSerializable
Wrap data
in a new Boxed
instance
data
: Data to wrap
Returns: New Boxed
instance
q
fun q([str] path) > Boxed
Query the json element at path
, if nothing matches return Boxed{}
path
: Path to query
Returns: Found Boxed
or Boxed{}
(which wraps null
)
string
str? string
When wrapped data is a string
boolean
bool? boolean
When wrapped data is a boolean
integer
int? integer
When wrapped data is a int
floating
float? floating
When wrapped data is a float
map
{str, Boxed}? map
When wrapped data is an object, object property values are themselves wrapped in a Boxed
list
[Boxed]? list
When wrapped data is a list, list elements are themselves warpped in a Boxed
stringValue
fun stringValue() > str
Returns: wrapped data string value or empty string if not a string
booleanValue
fun booleanValue() > bool
Returns: wrapped data boolean value or false
if not a boolean
integerValue
fun integerValue() > int
Returns: wrapped data number value or 0
if not an integer
floatingValue
fun floatingValue() > float
Returns: wrapped data number value or 0
if not a float
mapValue
fun mapValue() > {str, Boxed}
Returns: wrapped data map value or empty map if not a map
listValue
fun listValue() > [Boxed]
Returns: wrapped data list value or empty list if not a list
serialize
export extern fun serialize(any value) > any !> CircularReference, NotSerializable
Transform data
to data that can be serialized.
data
: Data to serialize
Return: Serializable data
jsonEncode
fun jsonEncode(Boxed data, {Boxed, void}? seen) > str
Encode a Boxed
instance to a JSON string
data
: Data to encode
Returns: The JSON string
jsonDecode
static fun jsonDecode(str json) > Boxed !> JsonParseError, WriteWhileReadingError
Decode string into a Boxed
instance
json
: The JSON string
Returns: A Boxed
instance wrapping the decoded data