mutate

fun JsonArray.mutate(block: JsonArrayMutationScope.() -> Unit): JsonArray(source)

Creates a new JsonArray by applying pointer-based mutations within block.

Mutations are applied eagerly in the order they appear in block. Returns a new JsonArray instance even if no mutations are made. The - segment in a leaf pointer path appends a new element at the end of the array.

Return

A new JsonArray containing all mutations applied to the original.

Receiver

The JsonArray to copy and mutate.

Parameters

block

A lambda with JsonArrayMutationScope as receiver, in which pointer-to-value assignments are expressed using the JsonArrayMutationScope.to infix functions, or elements are removed using JsonArrayMutationScope.remove.


fun JsonObject.mutate(block: JsonObjectMutationScope.() -> Unit): JsonObject(source)

Creates a new JsonObject by applying pointer-based mutations within block.

Mutations are applied eagerly in the order they appear in block. Returns a new JsonObject instance even if no mutations are made. New keys are inserted; existing keys are replaced.

Return

A new JsonObject containing all mutations applied to the original.

Receiver

The JsonObject to copy and mutate.

Parameters

block

A lambda with JsonObjectMutationScope as receiver, in which pointer-to-value assignments are expressed using the JsonObjectMutationScope.to infix functions, or keys are removed using JsonObjectMutationScope.remove.