JSON Pointer

Reference a single value within a JSON document by path (RFC 6901) — /foo/0/bar walks doc.foo[0].bar. A pointer is a sequence of /-prefixed reference tokens; the empty string points at the whole document. The two escapes (~1/, ~0~) let a token contain a literal slash or tilde.

get returns the referenced value or throws when the path does not resolve; parse exposes the decoded reference tokens. It is the path language JSON Patch (b.jsonPatch) builds on.

b.jsonPointer.parse(pointer) #

stable0.12.58

Decode an RFC 6901 JSON Pointer string into its array of reference tokens, unescaping ~1/ and ~0~. The empty string yields an empty array (the whole document); a non-empty pointer must begin with /.

b.jsonPointer.parse("/a~1b/m~0n");
// → ["a/b", "m~n"]

b.jsonPointer.get(doc, pointer) #

stable0.12.58

Return the value an RFC 6901 pointer references within a JSON document, walking object keys and array indices. Throws json-pointer/not-found when a token does not resolve (a missing key, an out-of-range or non-numeric array index, or descending into a primitive). The whole document is returned for the empty pointer.

b.jsonPointer.get({ foo: ["a", "b"] }, "/foo/1");
// → "b"

Last updated 2026-08-08T16:39:49.652Z by seeder.