Class JSONPointer
-
- All Implemented Interfaces:
public final class JSONPointerJSON Pointer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classJSONPointer.Companion
-
Constructor Summary
Constructors Constructor Description JSONPointer(String pointer)Construct a JSONPointerfrom the suppliedString, which must consist of zero or more tokens representing either an object property name or an array index, with each token preceded by a slash (/).
-
Method Summary
Modifier and Type Method Description final IntegergetDepth()final StringgetCurrent()final BooleanisRoot()final Array<String>tokensAsArray()Get the tokens that make up this pointer as an Array. final List<String>tokensAsList()Get the tokens that make up this pointer as a List. final JSONValuefind(JSONValue base)Find the JSONValue that this JSONPointerpoints to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value.final JSONValuefindOrNull(JSONValue base)Find the JSONValue that this JSONPointerpoints to within the specified base value, ornullif the pointer does not reference a valid location in the base value.final JSONObjectfindObject(JSONValue base)Find the JSONObject that this JSONPointerpoints to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value or if the value referenced is not a JSONObject.final JSONArrayfindArray(JSONValue base)Find the JSONArray that this JSONPointerpoints to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value or if the value referenced is not a JSONArray.final BooleanexistsIn(JSONValue json)Test whether this JSONPointerreferences a valid location in specified base value.final JSONPointerparent()Return a new JSONPointerreferencing the parent JSONObject or JSONArray of the value referenced by this pointer.final JSONPointerchild(String string)Return a new JSONPointerreferencing the nominated child property of the object referenced by this pointer.final JSONPointerchild(Integer index)Return a new JSONPointerreferencing the nominated child item of the array referenced by this pointer.final StringtoURIFragment()Convert the JSONPointerto a form suitable for use in a URI fragment.final JSONPointerlocateChild(JSONValue base, JSONValue target)Locate the specified target JSONValue in the base JSONValue, and return a JSONPointerpointing to it, based on the current pointer.final JSONReferenceref(JSONValue base)Create a JSONReference using this JSONPointerand the specified JSONValue base.Booleanequals(Object other)IntegerhashCode()StringtoString()-
-
Constructor Detail
-
JSONPointer
JSONPointer(String pointer)
Construct aJSONPointerfrom the suppliedString, which must consist of zero or more tokens representing either an object property name or an array index, with each token preceded by a slash (/).
-
-
Method Detail
-
getCurrent
final String getCurrent()
-
tokensAsArray
final Array<String> tokensAsArray()
Get the tokens that make up this pointer as an Array.
-
tokensAsList
final List<String> tokensAsList()
Get the tokens that make up this pointer as a List.
-
find
final JSONValue find(JSONValue base)
Find the JSONValue that this
JSONPointerpoints to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value.
-
findOrNull
final JSONValue findOrNull(JSONValue base)
Find the JSONValue that this
JSONPointerpoints to within the specified base value, ornullif the pointer does not reference a valid location in the base value.
-
findObject
final JSONObject findObject(JSONValue base)
Find the JSONObject that this
JSONPointerpoints to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value or if the value referenced is not a JSONObject.
-
findArray
final JSONArray findArray(JSONValue base)
Find the JSONArray that this
JSONPointerpoints to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value or if the value referenced is not a JSONArray.
-
existsIn
final Boolean existsIn(JSONValue json)
Test whether this
JSONPointerreferences a valid location in specified base value.
-
parent
final JSONPointer parent()
Return a new
JSONPointerreferencing the parent JSONObject or JSONArray of the value referenced by this pointer.
-
child
final JSONPointer child(String string)
Return a new
JSONPointerreferencing the nominated child property of the object referenced by this pointer.
-
child
final JSONPointer child(Integer index)
Return a new
JSONPointerreferencing the nominated child item of the array referenced by this pointer.
-
toURIFragment
final String toURIFragment()
Convert the
JSONPointerto a form suitable for use in a URI fragment.
-
locateChild
final JSONPointer locateChild(JSONValue base, JSONValue target)
Locate the specified target JSONValue in the base JSONValue, and return a
JSONPointerpointing to it, based on the current pointer. Returnsnullif not found.This will perform a depth-first search of the JSON structure.
-
ref
final JSONReference ref(JSONValue base)
Create a JSONReference using this
JSONPointerand the specified JSONValue base.
-
-
-
-