public final class JsonLoader extends Object
JsonNodes.
It should be noted here that the ObjectMapper used to read
everything has DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS
enabled. This is to be able to deal with floating point numbers of arbitrary
precision. Otherwise Jackson limits itself to double, for performance
reasons but also because, to quote its documentation, "[the] Javascript
standard specifies that all number handling should be done using 64-bit IEEE
754 floating point values" (therefore the equivalent of the double
primitive type). This is not JavaScript, however: this is JSON Schema.
| Modifier and Type | Field and Description |
|---|---|
private static ObjectMapper |
mapper
The mapper which does everything behind the scenes...
|
private static Class<JsonLoader> |
myself
A shortcut: myself as a
Class object. |
| Modifier | Constructor and Description |
|---|---|
private |
JsonLoader() |
| 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 |
fromURL(URL url)
Read a
JsonNode from an URL. |
private static final ObjectMapper mapper
private static final Class<JsonLoader> myself
Class object.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 problemsCopyright © 2012. All Rights Reserved.