public final class JsonLoader extends Object
JsonNodes.
This class uses JacksonUtils.getMapper() as an ObjectMapper to parse JSON inputs.
| Modifier and Type | Method and Description |
|---|---|
static JsonNode |
fromFile(File file)
Same as
fromPath(String), but this time the user supplies the
File object instead |
static JsonNode |
fromPath(String path)
Read a
JsonNode from a file on the local filesystem. |
static JsonNode |
fromReader(Reader reader)
|
static JsonNode |
fromResource(String resource)
Read a
JsonNode from a resource path. |
static JsonNode |
fromString(String json)
Read a
JsonNode from a string input |
static JsonNode |
fromURL(URL url)
Read a
JsonNode from an URL. |
public static JsonNode fromResource(String resource) throws IOException
JsonNode from a resource path. Explicitly throws an
IOException if the resource is null, instead of letting a
NullPointerException slip through...resource - The path to the resourceIOException - if the resource does not exist or there was a
problem loading it, or if the JSON document is invalidpublic static JsonNode fromURL(URL url) throws IOException
JsonNode from an URL.url - The URL to fetch the JSON document fromIOException - in case of network problems etc.public static JsonNode fromPath(String path) throws IOException
JsonNode from a file on the local filesystem.path - the path (relative or absolute) to the fileIOException - if this is not a file, if it cannot be read, etc.public static JsonNode fromFile(File file) throws IOException
fromPath(String), but this time the user supplies the
File object insteadfile - the File objectIOException - in many cases!public static JsonNode fromReader(Reader reader) throws IOException
reader - The readerIOException - if the reader has problemspublic static JsonNode fromString(String json) throws IOException
JsonNode from a string inputjson - the JSON as a stringIOException - could not read from stringCopyright © 2013. All Rights Reserved.