Class JsonPath


  • public class JsonPath
    extends java.lang.Object
    A property path represents a location in a JSON document. For example: foo.bar[5].baz

    Implemented as a singly-linked list where each PropertyPath represents one part of the path, linked to its parent.

    • Field Detail

      • ROOT

        public static final JsonPath ROOT
        Special path which represents the root of all paths. Is the ancestor of any path except itself. For example, this would be the parent of the path "foo"
    • Method Detail

      • isRoot

        public boolean isRoot()
      • getDepth

        public int getDepth()
      • getKey

        public java.lang.Object getKey()
      • getParent

        public JsonPath getParent()
      • getPathElements

        public JsonPath[] getPathElements()
        Returns the elements in this path's parent chain in order from ROOT downwards
      • getAsLinkedList

        public java.util.LinkedList<JsonPath> getAsLinkedList()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isAncestorOf

        public boolean isAncestorOf​(JsonPath element)
      • isRelatedTo

        public boolean isRelatedTo​(JsonPath other)
        Returns true if any of the following are true:
        1. This path is equal to the given path
        2. This path is an ancestor of the given path
        3. The given path is an ancestor of this path
      • isValidIdentifier

        public static boolean isValidIdentifier​(java.lang.String test)
      • createChildPath

        public JsonPath createChildPath​(java.lang.String childKey)
      • createChildPath

        public JsonPath createChildPath​(int index)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • parse

        public static JsonPath parse​(java.lang.String path)