@ThreadSafe
public final class JsonNodeReader
extends java.lang.Object
InputStream
s and Reader
s
This class wraps a Jackson ObjectMapper
so that it read one, and
only one, JSON text from a source. By default, when you read and map an
input source, Jackson will stop after it has read the first valid JSON text;
this means, for instance, that with this as an input:
[]]]
it will read the initial empty array ([]
) and stop there. This
class, instead, will peek to see whether anything is after the initial array,
and throw an exception if it finds anything.
Note: the input sources are closed by the read methods.
ObjectMapper.readValues(JsonParser, Class)
Constructor and Description |
---|
JsonNodeReader()
No-arg constructor (see description)
|
JsonNodeReader(com.fasterxml.jackson.databind.ObjectMapper mapper) |
Modifier and Type | Method and Description |
---|---|
com.fasterxml.jackson.databind.JsonNode |
fromInputStream(java.io.InputStream in)
Read a JSON value from an
InputStream |
com.fasterxml.jackson.databind.JsonNode |
fromReader(java.io.Reader r)
Read a JSON value from a
Reader |
public JsonNodeReader(com.fasterxml.jackson.databind.ObjectMapper mapper)
public JsonNodeReader()
public com.fasterxml.jackson.databind.JsonNode fromInputStream(java.io.InputStream in) throws java.io.IOException
InputStream
in
- the input streamjava.io.IOException
- malformed input, or problem encountered when reading
from the streampublic com.fasterxml.jackson.databind.JsonNode fromReader(java.io.Reader r) throws java.io.IOException
Reader
r
- the readerjava.io.IOException
- malformed input, or problem encountered when reading
from the reader