Search in sources :

Example 6 with InvalidPathException

use of com.jayway.jsonpath.InvalidPathException in project intellij-community by JetBrains.

the class JsonPathResponseHandler method extractRawValue.

@Nullable
private Object extractRawValue(@NotNull Selector selector, @NotNull String source) throws Exception {
    if (StringUtil.isEmpty(selector.getPath())) {
        return null;
    }
    JsonPath jsonPath = lazyCompile(selector.getPath());
    Object value;
    try {
        value = jsonPath.read(source);
    } catch (InvalidPathException e) {
        throw new Exception(String.format("JsonPath expression '%s' doesn't match", selector.getPath()), e);
    }
    if (value == null) {
        return null;
    }
    return value;
}
Also used : JsonPath(com.jayway.jsonpath.JsonPath) InvalidPathException(com.jayway.jsonpath.InvalidPathException) InvalidPathException(com.jayway.jsonpath.InvalidPathException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

InvalidPathException (com.jayway.jsonpath.InvalidPathException)6 JsonPath (com.jayway.jsonpath.JsonPath)2 LinkedList (java.util.LinkedList)2 Predicate (com.jayway.jsonpath.Predicate)1 Path (com.jayway.jsonpath.internal.Path)1 ParamType (com.jayway.jsonpath.internal.function.ParamType)1 Parameter (com.jayway.jsonpath.internal.function.Parameter)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1