No matching definitions.

json/patch

src/json/patch.tur
defn

json-get-in

(json-get-in [doc :int path :cstr] :cstr)

look up a value at a dot-separated path.

doc:int doc handle from json-parse
pathdot-separated key path, e.g. "user.address.city"

:cstr -- the matched value serialized as JSON, or "" if not found

(json-get-in doc "user.name")  ; => "\"Alice\""

Since: P4

defn

json-set-in

(json-set-in [doc :int path :cstr value :cstr] :ptr<void>)

return a new doc with the value at a dot-separated path replaced.

doc:int doc handle from json-parse
pathdot-separated key path, e.g. "user.name"
valueJSON string for the new value, e.g. "\"Bob\""

result<:int> -- ok(new-doc-handle) on success, err(:cstr message) on failure. The original doc handle is unchanged. The caller must json-free the new handle.

(let [r (json-set-in doc "x" "42")]
    (when (ok? r) (println (json-emit (ok-val r)))))

Since: P4

defn

json-merge

(json-merge [base :int overlay :int] :ptr<void>)

shallow-merge two JSON objects, returning a new doc.

base:int doc handle for the base object
overlay:int doc handle whose keys overwrite base keys

result<:int> -- ok(new-doc-handle) with merged object, or err(:cstr). The original handles are unchanged. Caller must json-free the new handle.

(let [r (json-merge base overlay)]
    (when (ok? r) (println (json-emit (ok-val r)))))

Since: P4

Internal definitions
__ok
__err