|
|
@ -259,7 +259,7 @@ public class JsonPath { |
|
|
|
InputStream in = null; |
|
|
|
InputStream in = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
in = HttpProviderFactory.getProvider().get(jsonURL); |
|
|
|
in = HttpProviderFactory.getProvider().get(jsonURL); |
|
|
|
return read(configuration.jsonProvider().parse(in), configuration); |
|
|
|
return read(in, "UTF-8", configuration); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
Utils.closeQuietly(in); |
|
|
|
Utils.closeQuietly(in); |
|
|
|
} |
|
|
|
} |
|
|
@ -297,7 +297,7 @@ public class JsonPath { |
|
|
|
FileInputStream fis = null; |
|
|
|
FileInputStream fis = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
fis = new FileInputStream(jsonFile); |
|
|
|
fis = new FileInputStream(jsonFile); |
|
|
|
return read(configuration.jsonProvider().parse(fis), configuration); |
|
|
|
return read(fis, configuration); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
Utils.closeQuietly(fis); |
|
|
|
Utils.closeQuietly(fis); |
|
|
|
} |
|
|
|
} |
|
|
@ -331,7 +331,29 @@ public class JsonPath { |
|
|
|
notNull(configuration, "configuration can not be null"); |
|
|
|
notNull(configuration, "configuration can not be null"); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
return read(configuration.jsonProvider().parse(jsonInputStream), configuration); |
|
|
|
return read(jsonInputStream, "UTF-8", configuration); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
Utils.closeQuietly(jsonInputStream); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Applies this JsonPath to the provided json input stream |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param jsonInputStream input stream to read from |
|
|
|
|
|
|
|
* @param configuration configuration to use |
|
|
|
|
|
|
|
* @param <T> expected return type |
|
|
|
|
|
|
|
* @return list of objects matched by the given path |
|
|
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
|
|
|
|
public <T> T read(InputStream jsonInputStream, String charset, Configuration configuration) throws IOException { |
|
|
|
|
|
|
|
notNull(jsonInputStream, "json input stream can not be null"); |
|
|
|
|
|
|
|
notNull(charset, "charset can not be null"); |
|
|
|
|
|
|
|
notNull(configuration, "configuration can not be null"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return read(configuration.jsonProvider().parse(jsonInputStream, charset), configuration); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
Utils.closeQuietly(jsonInputStream); |
|
|
|
Utils.closeQuietly(jsonInputStream); |
|
|
|
} |
|
|
|
} |
|
|
|