TinyMUX

Json_mod()

Functions

Description

FUNCTION: json_mod(<json>, <operation>, <path>[, <value>])

Modifies a JSON value and returns the result. Supported operations are: set, insert, replace, remove, and patch.

Paths use SQLite JSON path syntax (e.g., $.key for object members, $[0] for array elements).

Examples

> say json_mod({“a”:1}, set, $.b, 2)

You say, “{“a”:1,“b”:2}”

> say json_mod({“a”:1,“b”:2}, remove, $.b)

You say, “{“a”:1}”

> say json_mod([1,2,3], set, $[1], 99)

You say, “[1,99,3]”

json(), json_query()