public class JsonPointer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JsonPointer.Builder
This class allows the user to build a JsonPointer in steps, using exactly one segment in each
step.
|
Constructor and Description |
---|
JsonPointer(List<String> refTokens) |
JsonPointer(String pointer)
Pre-parses and initializes a new
JSONPointer instance. |
Modifier and Type | Method and Description |
---|---|
static JsonPointer.Builder |
builder()
Static factory method for
JsonPointer.Builder . |
Object |
queryFrom(Object document)
Evaluates this JSON Pointer on the given
document . |
String |
toString()
Returns a string representing the JsonPointer path value using string representation
|
String |
toURIFragment()
Returns a string representing the JsonPointer path value using URI fragment identifier
representation
|
public JsonPointer(String pointer)
JSONPointer
instance. If you want to evaluate the same
JSON Pointer on different JSON documents then it is recommended to keep the JSONPointer
instances due to performance considerations.pointer
- the JSON String or URI Fragment representation of the JSON pointer.IllegalArgumentException
- if pointer
is not a valid JSON pointerpublic static JsonPointer.Builder builder()
JsonPointer.Builder
. Example usage:
JsonPointer pointer = JsonPointer.builder()
.append("obj")
.append("other~key").append("another/key")
.append("\"")
.append(0)
.build();
JsonPointer
instance by
chained JsonPointer.Builder.append(String)
calls.public Object queryFrom(Object document) throws JsonPointerException
document
. The document
is usually a
JSONObject
or a JSONArray
instance, but the empty JSON Pointer (""
) can
be evaluated on any JSON values and in such case the returned value will be document
itself.document
- the JSON document which should be the subject of querying.JSONPointerException
- if an error occurs during evaluationJsonPointerException
public String toString()
public String toURIFragment()
Copyright © 2018 Terra Software Informatics LLC.. All rights reserved.