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

fun string() > str?

When wrapped data is a string

boolean

fun boolean() > bool?

When wrapped data is a boolean

integer

fun integer() > int?

When wrapped data is a int

floating

fun floating() > float?

When wrapped data is a float

map

fun map() > {str: Boxed}?

When wrapped data is an object, object property values are themselves wrapped in a Boxed

list

fun list() > [Boxed]?

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.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

fun serialize(any value) > any !> CircularReference, NotSerializable

Transform value to data that can be serialized.

  • value: Data to serialize

Return: Serializable data

jsonEncode

fun jsonEncode(Boxed data) > str !> CircularReference, NotSerializable

Encode a Boxed instance to a JSON string

  • data: Data to encode

Returns: The JSON string

jsonDecode

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

Last Updated:
Contributors: hshq, Benoit Giannangeli