Class: JSONPointer
Identify a single value in JSON-like data, as per RFC 6901.
Constructors
new JSONPointer()
new JSONPointer(
pointer
):JSONPointer
Parameters
pointer
string
A string representation of a JSON Pointer.
Returns
Defined in
Properties
tokens
tokens:
string
[]
Defined in
Methods
exists()
exists(
value
):boolean
Return true if this pointer can be resolved against value.
Note that JSONPointer.resolve()
can return legitimate falsy values
that form part of the target JSON document. This method will return
true
if a falsy value is found.
Parameters
value
Returns
boolean
Defined in
getItem()
protected
getItem(val
,token
,idx
):JSONValue
Parameters
val
token
string
idx
number
Returns
Defined in
isRelativeTo()
isRelativeTo(
pointer
):boolean
Return true if this pointer points to a child of pointer.
Parameters
pointer
Returns
boolean
Defined in
join()
join(...
tokens
):JSONPointer
Join this pointer with tokens.
Parameters
tokens
...string
[]
JSON Pointer strings, possibly without leading slashes.
If a token or "part" does have a leading slash, the previous pointer is
ignored and a new JSONPointer
is created, then processing of the
remaining tokens continues.
Returns
A new JSON Pointer that is the concatenation of all tokens or "parts".
Defined in
parent()
parent():
JSONPointer
Return this pointer's parent as a new JSONPointer
.
If this pointer points to the document root, this is returned.
Returns
Defined in
parse()
protected
parse(pointer
):string
[]
Parameters
pointer
string
Returns
string
[]
Defined in
resolve()
resolve(
value
,fallback
):JSONValue
Resolve this pointer against JSON-like data value.
Parameters
value
The target JSON-like value, possibly loaded using
JSON.parse()
.
fallback
MaybeJSONValue
= UNDEFINED
A default value to return if value has no
path matching pointer
.
Returns
The value identified by pointer or, if given, the fallback
value in the even of a JSONPointerResolutionError
.
Throws
JSONPointerResolutionError If the value pointed to by pointer does not exist in value, and no fallback value is given.
Defined in
resolveWithParent()
resolveWithParent(
value
): [MaybeJSONValue
,MaybeJSONValue
]
Parameters
value
Returns
[MaybeJSONValue
, MaybeJSONValue
]
Defined in
to()
to(
rel
):JSONPointer
Parameters
rel
string
| RelativeJSONPointer
Returns
Defined in
toString()
toString():
string
Returns
string
Defined in
encode()
static
encode(tokens
):string
Parameters
tokens
string
[]
Returns
string