public final class JsonLoader
extends java.lang.Object
JsonNode
s.
This class uses a JsonNodeReader
to parse JSON inputs.
JsonNodeReader
Modifier and Type | Method and Description |
---|---|
static com.fasterxml.jackson.databind.JsonNode |
fromFile(java.io.File file)
Same as
fromPath(String) , but this time the user supplies the
File object instead |
static com.fasterxml.jackson.databind.JsonNode |
fromPath(java.lang.String path)
Read a
JsonNode from a file on the local filesystem. |
static com.fasterxml.jackson.databind.JsonNode |
fromReader(java.io.Reader reader)
Read a
JsonNode from a user supplied Reader |
static com.fasterxml.jackson.databind.JsonNode |
fromResource(java.lang.String resource)
Read a
JsonNode from a resource path. |
static com.fasterxml.jackson.databind.JsonNode |
fromString(java.lang.String json)
Read a
JsonNode from a string input |
static com.fasterxml.jackson.databind.JsonNode |
fromURL(java.net.URL url)
Read a
JsonNode from an URL. |
public static com.fasterxml.jackson.databind.JsonNode fromResource(@Nonnull java.lang.String resource) throws java.io.IOException
JsonNode
from a resource path.
This method first tries and loads the resource using Class.getResource(String)
; if not found, is tries and uses the context
classloader and if this is not found, this class's classloader.
This method throws an IOException
if the resource does not
exist.
resource
- the path to the resource (must begin
with a /
)java.lang.IllegalArgumentException
- resource path does not begin with a
/
java.io.IOException
- there was a problem loading the resource, or the JSON
document is invalidpublic static com.fasterxml.jackson.databind.JsonNode fromURL(java.net.URL url) throws java.io.IOException
JsonNode
from an URL.url
- The URL to fetch the JSON document fromjava.io.IOException
- in case of network problems etc.public static com.fasterxml.jackson.databind.JsonNode fromPath(java.lang.String path) throws java.io.IOException
JsonNode
from a file on the local filesystem.path
- the path (relative or absolute) to the filejava.io.IOException
- if this is not a file, if it cannot be read, etc.public static com.fasterxml.jackson.databind.JsonNode fromFile(java.io.File file) throws java.io.IOException
fromPath(String)
, but this time the user supplies the
File
object insteadfile
- the File objectjava.io.IOException
- in many cases!public static com.fasterxml.jackson.databind.JsonNode fromReader(java.io.Reader reader) throws java.io.IOException
JsonNode
from a user supplied Reader
reader
- The readerjava.io.IOException
- if the reader has problemspublic static com.fasterxml.jackson.databind.JsonNode fromString(java.lang.String json) throws java.io.IOException
JsonNode
from a string inputjson
- the JSON as a stringjava.io.IOException
- could not read from string