Package com.github.tnakamot.json.pointer
Class JSONPointer
- java.lang.Object
-
- com.github.tnakamot.json.pointer.JSONPointer
-
-
Constructor Summary
Constructors Constructor Description JSONPointer(JSONValueString value)
Create a new JSON Pointer instance from a JSON string value.JSONPointer(JSONValueString value, boolean fragment)
Create a new JSON Pointer instance from a JSON string value.JSONPointer(String text)
Create a new JSON Pointer instance from a Java String.JSONPointer(String text, boolean fragment)
Create a new JSON Pointer instance from a Java String.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JSONValue
evaluate(@NotNull JSONValue root)
Evaluate this JSON pointer in the context of the given root value of a JSON document.String
text()
Return the pointer string.JSONPointerReferenceToken[]
tokens()
Return the reference tokens.
-
-
-
Constructor Detail
-
JSONPointer
public JSONPointer(String text) throws InvalidJSONPointerSyntaxException
Create a new JSON Pointer instance from a Java String.- Parameters:
text
- String which represents a JSON pointer- Throws:
InvalidJSONPointerSyntaxException
- when the given String cannot be interpreted as a JSON Pointer.
-
JSONPointer
public JSONPointer(String text, boolean fragment) throws InvalidJSONPointerSyntaxException
Create a new JSON Pointer instance from a Java String.- Parameters:
text
- String which represents a JSON pointerfragment
- specify true to handle the given string as a URI fragment identifier starting with '#".- Throws:
InvalidJSONPointerSyntaxException
- when the given String cannot be interpreted as a JSON Pointer.
-
JSONPointer
public JSONPointer(JSONValueString value) throws InvalidJSONPointerSyntaxException
Create a new JSON Pointer instance from a JSON string value.- Parameters:
value
- a JSON string value which represents a JSON pointer- Throws:
InvalidJSONPointerSyntaxException
- when the given string cannot be interpreted as a JSON Pointer.
-
JSONPointer
public JSONPointer(JSONValueString value, boolean fragment) throws InvalidJSONPointerSyntaxException
Create a new JSON Pointer instance from a JSON string value.- Parameters:
value
- a JSON string value which represents a JSON pointerfragment
- specify true to handle the given string as a URI fragment identifier starting with '#".- Throws:
InvalidJSONPointerSyntaxException
- when the given string cannot be interpreted as a JSON Pointer.
-
-
Method Detail
-
tokens
public JSONPointerReferenceToken[] tokens()
Return the reference tokens.- Returns:
- reference tokens
-
text
public String text()
Return the pointer string.- Returns:
- the original pointer string
-
evaluate
public JSONValue evaluate(@NotNull @NotNull JSONValue root) throws InvalidJSONPointerWithTokenException
Evaluate this JSON pointer in the context of the given root value of a JSON document.- Parameters:
root
- root value of a JSON document- Returns:
- the JSON value that this JSON Pointer points to
- Throws:
InvalidJSONPointerWithTokenException
- when the JSON Pointer does not point to an existing JSON value
-
-