Class JSONPointer

  • All Implemented Interfaces:

    
    public final class JSONPointer
    
                        

    JSON Pointer.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class JSONPointer.Companion
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONPointer(String pointer) Construct a JSONPointer from the supplied String, 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 (/).
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer getDepth()
      final String getCurrent()
      final Boolean isRoot()
      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 JSONValue find(JSONValue base) Find the JSONValue that this JSONPointer points to within the specified base value, or throw an exception if the pointer does not reference a valid location in the base value.
      final JSONValue findOrNull(JSONValue base) Find the JSONValue that this JSONPointer points to within the specified base value, or null if the pointer does not reference a valid location in the base value.
      final JSONObject findObject(JSONValue base) Find the JSONObject that this JSONPointer points 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 JSONArray findArray(JSONValue base) Find the JSONArray that this JSONPointer points 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 Boolean existsIn(JSONValue json) Test whether this JSONPointer references a valid location in specified base value.
      final JSONPointer parent() Return a new JSONPointer referencing the parent JSONObject or JSONArray of the value referenced by this pointer.
      final JSONPointer child(String string) Return a new JSONPointer referencing the nominated child property of the object referenced by this pointer.
      final JSONPointer child(Integer index) Return a new JSONPointer referencing the nominated child item of the array referenced by this pointer.
      final String toURIFragment() Convert the JSONPointer to a form suitable for use in a URI fragment.
      final JSONPointer locateChild(JSONValue base, JSONValue target) Locate the specified target JSONValue in the base JSONValue, and return a JSONPointer pointing to it, based on the current pointer.
      final JSONReference ref(JSONValue base) Create a JSONReference using this JSONPointer and the specified JSONValue base.
      Boolean equals(Object other)
      Integer hashCode()
      String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSONPointer

        JSONPointer(String pointer)
        Construct a JSONPointer from the supplied String, 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

      • find

         final JSONValue find(JSONValue base)

        Find the JSONValue that this JSONPointer points 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 JSONPointer points to within the specified base value, or null if the pointer does not reference a valid location in the base value.

      • findObject

         final JSONObject findObject(JSONValue base)

        Find the JSONObject that this JSONPointer points 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 JSONPointer points 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 JSONPointer references a valid location in specified base value.

      • parent

         final JSONPointer parent()

        Return a new JSONPointer referencing the parent JSONObject or JSONArray of the value referenced by this pointer.

      • child

         final JSONPointer child(String string)

        Return a new JSONPointer referencing the nominated child property of the object referenced by this pointer.

      • child

         final JSONPointer child(Integer index)

        Return a new JSONPointer referencing the nominated child item of the array referenced by this pointer.

      • toURIFragment

         final String toURIFragment()

        Convert the JSONPointer to 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 JSONPointer pointing to it, based on the current pointer. Returns null if not found.

        This will perform a depth-first search of the JSON structure.