Skip to content

JsonArray

[Source]

Immutable JSON array backed by a persistent vector.

Construction is via chained .push() calls, each returning a new array with structural sharing:

let arr = JsonArray
  .push(I64(1))
  .push(I64(2))
  .push(I64(3))
class val JsonArray is
  Stringable box

Implements


Constructors

create

[Source]

new val create(
  data': Vec[JsonValue] val = qualify)
: JsonArray val^

Parameters

Returns


Public Functions

apply

[Source]

Look up a value by index. Raises if out of bounds.

fun box apply(
  i: USize val)
: JsonValue ?

Parameters

Returns


size

[Source]

Number of elements.

fun box size()
: USize val

Returns


update

[Source]

Return a new array with element at index i replaced. Raises if out of bounds.

fun box update(
  i: USize val,
  value: JsonValue)
: JsonArray val ?

Parameters

Returns


push

[Source]

Return a new array with value appended.

fun box push(
  value: JsonValue)
: JsonArray val

Parameters

Returns


pop

[Source]

Return (new array without last element, removed element). Raises if empty.

fun box pop()
: (JsonArray val , JsonValue) ?

Returns


values

[Source]

Iterate over values.

fun box values()
: VecValues[JsonValue] ref

Returns


pairs

[Source]

Iterate over (index, value) pairs.

fun box pairs()
: VecPairs[JsonValue] ref

Returns


string

[Source]

Compact JSON serialization.

fun box string()
: String iso^

Returns


pretty_string

[Source]

Pretty-printed JSON serialization.

fun box pretty_string(
  indent: String val = "  ")
: String iso^

Parameters

Returns