Class JSONPath

  • All Implemented Interfaces:
    JSONAware

    public class JSONPath
    extends Object
    implements JSONAware
    Since:
    1.2.0
    Author:
    wenshao[szujobs@hotmail.com]
    • Constructor Detail

      • JSONPath

        public JSONPath​(String path)
      • JSONPath

        public JSONPath​(String path,
                        boolean ignoreNullValue)
    • Method Detail

      • isRef

        public boolean isRef()
      • eval

        public <T> T eval​(Object rootObject,
                          Type clazz,
                          ParserConfig parserConfig)
        Parameters:
        rootObject -
        clazz -
        parserConfig -
        Returns:
        Since:
        1.2.76
      • eval

        public <T> T eval​(Object rootObject,
                          Type clazz)
        Parameters:
        rootObject -
        clazz -
        Returns:
        Since:
        1.2.76
      • contains

        public boolean contains​(Object rootObject)
      • containsValue

        public boolean containsValue​(Object rootObject,
                                     Object value)
      • size

        public int size​(Object rootObject)
      • keySet

        public Set<?> keySet​(Object rootObject)
        Extract keySet or field names from rootObject on this JSONPath.
        Parameters:
        rootObject - Can be a map or custom object. Array and Collection are not supported.
        Returns:
        Set of keys, or null if not supported.
      • patchAdd

        public void patchAdd​(Object rootObject,
                             Object value,
                             boolean replace)
      • arrayAdd

        public void arrayAdd​(Object rootObject,
                             Object... values)
      • remove

        public boolean remove​(Object rootObject)
      • set

        public boolean set​(Object rootObject,
                           Object value)
      • set

        public boolean set​(Object rootObject,
                           Object value,
                           boolean p)
      • eval

        public static Object eval​(Object rootObject,
                                  String path,
                                  boolean ignoreNullValue)
      • size

        public static int size​(Object rootObject,
                               String path)
      • keySet

        public static Set<?> keySet​(Object rootObject,
                                    String path)
        Compile jsonPath and use it to extract keySet or field names from rootObject.
        Parameters:
        rootObject - Can be a map or custom object. Array and Collection are not supported.
        path - JSONPath string to be compiled.
        Returns:
        Set of keys, or null if not supported.
      • contains

        public static boolean contains​(Object rootObject,
                                       String path)
      • containsValue

        public static boolean containsValue​(Object rootObject,
                                            String path,
                                            Object value)
      • arrayAdd

        public static void arrayAdd​(Object rootObject,
                                    String path,
                                    Object... values)
      • remove

        public static boolean remove​(Object root,
                                     String path)
      • compile

        public static JSONPath compile​(String path,
                                       boolean ignoreNullValue)
      • read

        public static Object read​(String json,
                                  String path)
        Parameters:
        json -
        path -
        Returns:
        Since:
        1.2.9
      • read

        public static <T> T read​(String json,
                                 String path,
                                 Type clazz,
                                 ParserConfig parserConfig)
        Parameters:
        json -
        path -
        clazz -
        parserConfig -
        Returns:
        Since:
        1.2.76
      • read

        public static <T> T read​(String json,
                                 String path,
                                 Type clazz)
        Parameters:
        json -
        path -
        clazz -
        Returns:
        Since:
        1.2.76
      • extract

        public static Object extract​(String json,
                                     String path,
                                     ParserConfig config,
                                     int features,
                                     Feature... optionFeatures)
        Parameters:
        json -
        path -
        Returns:
        Since:
        1.2.51
      • getPath

        public String getPath()
      • setArrayItem

        public boolean setArrayItem​(JSONPath path,
                                    Object currentObject,
                                    int index,
                                    Object value)
      • removeArrayItem

        public boolean removeArrayItem​(JSONPath path,
                                       Object currentObject,
                                       int index)
      • reserveToArray

        public static Object reserveToArray​(Object object,
                                            String... paths)
      • reserveToObject

        public static Object reserveToObject​(Object object,
                                             String... paths)