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

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


print

[Source]

Compact JSON serialization.

fun box print()
: String iso^

Returns


pretty_print

[Source]

Pretty-printed JSON serialization.

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

Parameters

Returns