@SuppressWarnings("unchecked")
    public <T> T read(Object jsonObject, Configuration configuration) {
        boolean optAsPathList = configuration.containsOption(AS_PATH_LIST);
        boolean optAlwaysReturnList = configuration.containsOption(Option.ALWAYS_RETURN_LIST);
        boolean optSuppressExceptions = configuration.containsOption(Option.SUPPRESS_EXCEPTIONS);

        try {
            if (path.isFunctionPath()) {
                if (optAsPathList || optAlwaysReturnList) {
                    throw new JsonPathException("Options " + AS_PATH_LIST + " and " + ALWAYS_RETURN_LIST + " are not allowed when using path functions!");
                }
                return path.evaluate(jsonObject, jsonObject, configuration).getValue(true);

            } else if (optAsPathList) {
                return (T) path.evaluate(jsonObject, jsonObject, configuration).getPath();

            } else {
                Object res = path.evaluate(jsonObject, jsonObject, configuration).getValue(false);
                if (optAlwaysReturnList && path.isDefinite()) {
                    Object array = configuration.jsonProvider().createArray();
                    configuration.jsonProvider().setArrayIndex(array, 0, res);
                    return (T) array;
                } else {
                    return (T) res;
                }
            }
        } catch (RuntimeException e) {
            if (!optSuppressExceptions) {
                throw e;
            } else {
                if (optAsPathList) {
                    return (T) configuration.jsonProvider().createArray();
                } else {
                    if (optAlwaysReturnList) {
                        return (T) configuration.jsonProvider().createArray();
                    } else {
                        return (T) (path.isDefinite() ? null : configuration.jsonProvider().createArray());
                    }
                }
            }
        }
    }
@ SuppressWarnings ( "unchecked" ) public < T > T read ( Object jsonObject , Configuration configuration ) { boolean optAsPathList = configuration . containsOption ( AS_PATH_LIST ) ; boolean optAlwaysReturnList = configuration . containsOption ( Option . ALWAYS_RETURN_LIST ) ; boolean optSuppressExceptions = configuration . containsOption ( Option . SUPPRESS_EXCEPTIONS ) ; try { if ( path . isFunctionPath ( ) ) { if ( optAsPathList || optAlwaysReturnList ) { throw new JsonPathException ( "Options " + AS_PATH_LIST + " and " + ALWAYS_RETURN_LIST + " are not allowed when using path functions!" ) ; } return path . evaluate ( jsonObject , jsonObject , configuration ) . getValue ( true ) ; } else if ( optAsPathList ) { return ( T ) path . evaluate ( jsonObject , jsonObject , configuration ) . getPath ( ) ; } else { Object res = path . evaluate ( jsonObject , jsonObject , configuration ) . getValue ( false ) ; if ( optAlwaysReturnList && path . isDefinite ( ) ) { Object array = configuration . jsonProvider ( ) . createArray ( ) ; configuration . jsonProvider ( ) . setArrayIndex ( array , 0 , res ) ; return ( T ) array ; } else { return ( T ) res ; } } } catch ( RuntimeException e ) { if ( ! optSuppressExceptions ) { throw e ; } else { if ( optAsPathList ) { return ( T ) configuration . jsonProvider ( ) . createArray ( ) ; } else { if ( optAlwaysReturnList ) { return ( T ) configuration . jsonProvider ( ) . createArray ( ) ; } else { return ( T ) ( path . isDefinite ( ) ? null : configuration . jsonProvider ( ) . createArray ( ) ) ; } } } } }
Applies this JsonPath to the provided json document.
Note that the document must be identified as either a List or Map by
the {@link JsonProvider}

@param jsonObject    a container Object
@param configuration configuration to use
@param <T>           expected return type
@return object(s) matched by the given path