/** * Get the result of an Object path expression as a list. * * @param path The Object path. * @param <T> The list type * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <T> List<T> getList(String path) { return get(path); }
/** * Instantiate a new JsonPath instance. * * @param reader The reader containing the Object document */ public static JsonPath from(Reader reader) { return new JsonPath(reader); }
/** * Instantiate a new JsonPath instance. * * @param stream The stream containing the Object document */ public JsonPath(InputStream stream) { jsonParser = parseInputStream(stream); }
/** * Instantiate a new JsonPath instance. * * @param text The text containing the Object document */ public JsonPath(String text) { jsonParser = parseText(text); }
@Override public Object doParseWith(final ConfigurableJsonSlurper slurper) { return new ExceptionCatcher() { protected Object method() throws Exception { return slurper.parse(new FileReader(file)); } }.invoke(); } };
@Override public Object doParseWith(final ConfigurableJsonSlurper slurper) { return new ExceptionCatcher() { protected Object method() throws Exception { return slurper.parse(toReader(url.openStream())); } }.invoke(); } };
@Override public Object doParseWith(final ConfigurableJsonSlurper slurper) { return new ExceptionCatcher() { protected Object method() throws Exception { return slurper.parse(toReader(stream)); } }.invoke(); } };
public final Object parseWith(ConfigurableJsonSlurper slurper) { if (json == null) { json = doParseWith(slurper); } return json; }
/** * Get the result of an Object path expression as a map. * * @param path The Object path. * @param <K> The type of the expected key * @param <V> The type of the expected value * @return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <K, V> Map<K, V> getMap(String path) { return get(path); }
/** * Instantiate a new JsonPath instance. * * @param url The URI containing the Object document */ public static JsonPath from(URL url) { return new JsonPath(url); }
/** * Get the result of an Object path expression as a map. * * @param path The Object path. * @param <K> The type of the expected key * @param <V> The type of the expected value * @return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <K, V> Map<K, V> getMap(String path) { return get(path); }
/** * Instantiate a new JsonPath instance. * * @param reader The reader containing the Object document */ public static JsonPath given(Reader reader) { return new JsonPath(reader); }
/** * Instantiate a new JsonPath instance. * * @param stream The stream containing the Object document */ public static JsonPath with(InputStream stream) { return new JsonPath(stream); }
/** * Instantiate a new JsonPath instance. * * @param stream The stream containing the Object document */ public static JsonPath from(InputStream stream) { return new JsonPath(stream); }
/** * Instantiate a new JsonPath instance. * * @param url The URI containing the Object document */ public static JsonPath with(URL url) { return new JsonPath(url); }
/** * Instantiate a new JsonPath instance. * * @param file The file containing the Object document */ public static JsonPath from(File file) { return new JsonPath(file); }
/** * Configure JsonPath to with a specific JsonPathConfig. * * @param config The JsonPath config * @return a new JsonPath instance */ public JsonPath using(JsonPathConfig config) { return new JsonPath(this, config); }
/** * Instantiate a new JsonPath instance. * * @param url The URL containing the Object document */ public static JsonPath given(URL url) { return new JsonPath(url); }
/** * Instantiate a new JsonPath instance. * * @param url The URI containing the Object document */ public static JsonPath with(URL url) { return new JsonPath(url); }
/** * Instantiate a new JsonPath instance. * * @param file The file containing the Object document */ public static JsonPath from(File file) { return new JsonPath(file); }