This library provides JSON Patch procedures.
The specification of JSON Patch is defined by the RFC 6902.
The following example shows simple usage of the library:
This is an input file named example.json
.
{
"id": 1234,
"data": {
"datum0": [0, 1, 2],
"datum1": [3, 4]
}
}
(import (rnrs) (text json patch) (text json))
(define data-patcher
(json-patcher
'(#(("op" . "replace") ("path" . "/data/datum0") ("value" . "ok"))
#(("op" . "remove") ("path" . "/data/datum1")))))
(let ((json (call-with-input-file "example.json" json-read)))
(data-patcher json))
#((id . 1234) (data . #((datum0 . ok))))
Returns a procedure takes one argument which must be a list or vector representing JSON object. The given patch must be a list of vector which represents JSON patch.
Returns #t if the given obj is an instance of &json-patch
condition.
&json-patch
is the base condition of this library. The hierarchy is
the following:
&json-patch
+ &json-patch:runtime (path)
+ &json-patch-path-not-found
+ &json-patch-illegal-type
+ &json-patch:compile (patch)
Returns #t if the given obj is an instance of
&json-patch:compile
condition.
Returns #t if the given obj is an instance of
&json-patch:runtime
condition.
Returns #t if the given obj is an instance of
&json-patch-path-not-found
condition.
Returns #t if the given obj is an instance of
&json-patch-illegal-type
condition.
Returns the path
field of the given json-patch-error if
the condition is type of &json-patch-runtime
.
Returns the patch
field of the given json-patch-error if
the condition is type of &json-patch-compile
.
Flag to supress no such path error. The value must be either a symbol or a list of symbol of the name of the patch command. If the value is matched with the patch command, then the runtime doesn't raise a condition.
Creates JSON patch from given json0 and json1.
The returning patch is json1 to json1 format.