|
|
@ -255,12 +255,10 @@ public class JsonPath { |
|
|
|
|
|
|
|
|
|
|
|
result = filter.filter(result, configuration, contextFilters, inArrayContext); |
|
|
|
result = filter.filter(result, configuration, contextFilters, inArrayContext); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(result == null && !pathToken.isEndToken()){ |
|
|
|
if(result == null && !pathToken.isEndToken()){ |
|
|
|
throw new PathNotFoundException("Path token: '" + pathToken.getFragment() + "' not found."); |
|
|
|
throw new PathNotFoundException("Path token: '" + pathToken.getFragment() + "' not found."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!inArrayContext) { |
|
|
|
if (!inArrayContext) { |
|
|
|
inArrayContext = filter.isArrayFilter(); |
|
|
|
inArrayContext = filter.isArrayFilter(); |
|
|
|
} |
|
|
|
} |
|
|
@ -508,56 +506,140 @@ public class JsonPath { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------
|
|
|
|
// --------------------------------------------------------
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Static Fluent API
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// --------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Creates a {@link ParseContext} that can be used to parse a given JSON input. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param configuration configuration to use when parsing JSON |
|
|
|
|
|
|
|
* @return a parsing context based on given configuration |
|
|
|
|
|
|
|
*/ |
|
|
|
public static ParseContext using(Configuration configuration){ |
|
|
|
public static ParseContext using(Configuration configuration){ |
|
|
|
return new JsonReader(configuration); |
|
|
|
return new JsonReader(configuration); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Creates a {@link ParseContext} that will parse a given JSON input. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param provider provider to use when parsing JSON |
|
|
|
|
|
|
|
* @return a parsing context based on given provider |
|
|
|
|
|
|
|
*/ |
|
|
|
public static ParseContext using(JsonProvider provider){ |
|
|
|
public static ParseContext using(JsonProvider provider){ |
|
|
|
return new JsonReader(Configuration.builder().jsonProvider(provider).build()); |
|
|
|
return new JsonReader(Configuration.builder().jsonProvider(provider).build()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(Object json, Configuration configuration) { |
|
|
|
/** |
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
* Parses the given JSON input using the default {@link Configuration} and |
|
|
|
} |
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json input |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
public static ReadContext parse(Object json) { |
|
|
|
public static ReadContext parse(Object json) { |
|
|
|
return new JsonReader().parse(json); |
|
|
|
return new JsonReader().parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(String json, Configuration configuration){ |
|
|
|
/** |
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
* Parses the given JSON input using the default {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json string |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(String json) { |
|
|
|
|
|
|
|
return new JsonReader().parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(String json) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Parses the given JSON input using the default {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json stream |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(InputStream json) { |
|
|
|
return new JsonReader().parse(json); |
|
|
|
return new JsonReader().parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(InputStream json, Configuration configuration) { |
|
|
|
/** |
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
* Parses the given JSON input using the default {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json file |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(File json) throws IOException { |
|
|
|
|
|
|
|
return new JsonReader().parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(InputStream json) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Parses the given JSON input using the default {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json url |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(URL json) throws IOException { |
|
|
|
return new JsonReader().parse(json); |
|
|
|
return new JsonReader().parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(File json, Configuration configuration) throws IOException { |
|
|
|
/** |
|
|
|
|
|
|
|
* Parses the given JSON input using the provided {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json input |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(Object json, Configuration configuration) { |
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ReadContext parse(File json) throws IOException { |
|
|
|
/** |
|
|
|
return new JsonReader().parse(json); |
|
|
|
* Parses the given JSON input using the provided {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json input |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(String json, Configuration configuration){ |
|
|
|
|
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
* Parses the given JSON input using the provided {@link Configuration} and |
|
|
|
public static <T> T read(Configuration configuration, Object json, String path, Filter... filters){ |
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
return compile(path, filters).read(json, configuration); |
|
|
|
* |
|
|
|
|
|
|
|
* @param json input |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(InputStream json, Configuration configuration) { |
|
|
|
|
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
/** |
|
|
|
public static <T> T read(Configuration configuration, String json, String path, Filter... filters){ |
|
|
|
* Parses the given JSON input using the provided {@link Configuration} and |
|
|
|
return read(configuration, configuration.getProvider().parse(json), path, filters); |
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json input |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(File json, Configuration configuration) throws IOException { |
|
|
|
|
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Parses the given JSON input using the provided {@link Configuration} and |
|
|
|
|
|
|
|
* returns a {@link ReadContext} for path evaluation |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param json input |
|
|
|
|
|
|
|
* @return a read context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ReadContext parse(URL json, Configuration configuration) throws IOException { |
|
|
|
|
|
|
|
return new JsonReader(configuration).parse(json); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|