Parse and resolve JSON Pointers
Parse and resolve JSON Pointers
(as-key x)
Coerce x
to key (string or integer).
Coerce `x` to key (string or integer).
(as-path x)
Coerce x
to a path. If x
is a string, parse as JSON pointer.
Coerce `x` to a path. If `x` is a string, parse as JSON pointer.
(canonical-path document path)
(canonical-path document path throw-on-nil?)
Get the canonical version of path
in document
.
Given a document that may contain $ref pointers, and a path, return the equivalent path that contains no pointers. Throws an exception when cyclic references are encountered.
Returns nil when path does not point to a node in the document. If
throw-on-nil?
is provided and true, raise an error instead.
See also find
and get
.
Get the canonical version of `path` in `document`. Given a document that may contain $ref pointers, and a path, return the equivalent path that contains no pointers. Throws an exception when cyclic references are encountered. Returns nil when path does not point to a node in the document. If `throw-on-nil?` is provided and true, raise an error instead. See also `find` and `get`.
(find document path)
(find document path throw-on-nil?)
Find node and canonical path in document
.
Given a document that may contain $ref pointers, and a path, return a tuple (vector) of the canonical path and the node at that path. Throws an exception when cyclic references are encountered.
If path
is a string, it will be parsed as a JSON pointer. The
returned path is always a vector.
Returns nil when path does not point to a node in the document. If
throw-on-nil?
is provided and true, raise an error instead.
See also canonical-path
and pointer-path
.
Find node and canonical path in `document`. Given a document that may contain $ref pointers, and a path, return a tuple (vector) of the canonical path and the node at that path. Throws an exception when cyclic references are encountered. If `path` is a string, it will be parsed as a JSON pointer. The returned path is always a vector. Returns nil when path does not point to a node in the document. If `throw-on-nil?` is provided and true, raise an error instead. See also `canonical-path` and `pointer-path`.
(get document path)
(get document path throw-on-nil?)
Get node at path
in `document.
Given a document that may contain $ref pointers, and a path, return the equivalent path that contains no pointers. Throws an exception when cyclic references are encountered.
Returns nil when path does not point to a node in the document. If
throw-on-nil?
is provided and true, raise an error instead.
See also find
and get
.
Get node at `path` in `document. Given a document that may contain $ref pointers, and a path, return the equivalent path that contains no pointers. Throws an exception when cyclic references are encountered. Returns nil when path does not point to a node in the document. If `throw-on-nil?` is provided and true, raise an error instead. See also `find` and `get`.
(plain-ref? node)
Node is a plain ref if it has no other attributes than "$ref".
Node is a plain ref if it has no other attributes than "$ref".
(pointer-path pointer)
Parse a JSON Pointer as a path vector.
The returned path's keys are integers or strings.
Parse a JSON Pointer as a path vector. The returned path's keys are integers or strings.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close