Class JsonPathParser

    • Constructor Detail

      • JsonPathParser

        protected JsonPathParser​(JsonPathParser.Conf<?> builder)
        Protected constructor.
        Parameters:
        builder - Builder for this class.
        See Also:
        newBuilder()
    • Method Detail

      • newBuilder

        public static JsonPathParser.Conf<?> newBuilder()
        Get a new Builder
        Returns:
        New Builder instance.
      • getCollector

        protected org.jsfr.json.Collector getCollector​(java.lang.Object input)
        Get a matching Collector from the type of the input.
        Parameters:
        input - Any input type.
        Returns:
        The matching collector for the input.
        Throws:
        org.jsfr.json.exception.JsonSurfingException - When the input cannot be parsed into a Json String.
      • getOneValues

        protected <C> java.util.Map<java.lang.String,​C> getOneValues​(org.jsfr.json.Collector collector,
                                                                           java.lang.Class<C> clazz)
        Get one value for each entry in AbstractJsonParser.jsonCuts.
        Type Parameters:
        C - Type of value
        Parameters:
        collector - The collector to use.
        clazz - Type of the result values in the returned map.
        Returns:
        A map with Tuple [name, value] where value is one found by the matching key (json path) of AbstractJsonParser.jsonCuts.
      • getAllValues

        protected <C> java.util.Map<java.lang.String,​java.util.Collection<C>> getAllValues​(org.jsfr.json.Collector collector,
                                                                                                 java.lang.Class<C> clazz)
        Get all values for each entry in AbstractJsonParser.jsonCuts.
        Type Parameters:
        C - Type of value
        Parameters:
        collector - The collector to use.
        clazz - Type of the result values in the returned map.
        Returns:
        A map with Tuple [name, collection of values] where values are a collection of all found by the matching key (json path) of AbstractJsonParser.jsonCuts.
      • checkDataField

        protected void checkDataField()
        Throws:
        java.lang.IllegalArgumentException - When AbstractJsonParser.jsonCuts is empty but at least one entry is needed.
      • getOneFromOnePath

        public java.lang.Object getOneFromOnePath​(java.lang.Object jsonObject)
        Get one value from one path in AbstractJsonParser.jsonCuts [jsonPath, name].
        Parameters:
        jsonObject - The object to parse.
        Returns:
        The value found or null if nothing can be found.
      • getOneFromOnePath

        public <C> C getOneFromOnePath​(java.lang.Object jsonObject,
                                       java.lang.Class<C> clazz)
        Get one value from one path in AbstractJsonParser.jsonCuts [jsonPath, name].
        Type Parameters:
        C - Type of result values.
        Parameters:
        jsonObject - The object to parse.
        clazz - Class of result values.
        Returns:
        The value found or null if nothing can be found.
      • getOneFromAllPaths

        public java.util.Map<java.lang.String,​java.lang.Object> getOneFromAllPaths​(java.lang.Object jsonObject)
        Get one value from all paths in AbstractJsonParser.jsonCuts [jsonPath, name].
        Parameters:
        jsonObject - The object to parse.
        Returns:
        Map of [name, the value found].
      • getOneFromAllPaths

        public <C> java.util.Map<java.lang.String,​C> getOneFromAllPaths​(java.lang.Object jsonObject,
                                                                              java.lang.Class<C> clazz)
        Get one value from all paths in AbstractJsonParser.jsonCuts [jsonPath, name].
        Type Parameters:
        C - Type of result values.
        Parameters:
        jsonObject - The object to parse.
        clazz - Class of result values.
        Returns:
        Map of [name, the value found].
      • getAllFromOnePath

        public java.util.Collection<java.lang.Object> getAllFromOnePath​(java.lang.Object jsonObject)
        Get all matching values from one path in AbstractJsonParser.jsonCuts [jsonPath, name].
        Parameters:
        jsonObject - The object to parse.
        Returns:
        Collection of found values.
      • getAllFromOnePath

        public <C> java.util.Collection<C> getAllFromOnePath​(java.lang.Object jsonObject,
                                                             java.lang.Class<C> clazz)
        Get all matching values from one path in AbstractJsonParser.jsonCuts [jsonPath, name].
        Type Parameters:
        C - Type of result values.
        Parameters:
        jsonObject - The object to parse.
        clazz - Class of result values.
        Returns:
        Collection of found values.
      • getAllFromAllPaths

        public java.util.Map<java.lang.String,​java.util.Collection<java.lang.Object>> getAllFromAllPaths​(java.lang.Object jsonObject)
        Get all matching values from all paths in AbstractJsonParser.jsonCuts [jsonPath, name].
        Parameters:
        jsonObject - The object to parse.
        Returns:
        Map of [name, Collection of found values].
      • getAllFromAllPaths

        public <C> java.util.Map<java.lang.String,​java.util.Collection<C>> getAllFromAllPaths​(java.lang.Object jsonObject,
                                                                                                    java.lang.Class<C> clazz)
        Get all matching values from all paths in AbstractJsonParser.jsonCuts [jsonPath, name].
        Type Parameters:
        C - Type of result values.
        Parameters:
        jsonObject - The object to parse.
        clazz - Class of result values.
        Returns:
        Map of [name, Collection of found values].