@ThreadSafe public final class JsonNodeReader extends 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(ObjectMapper mapper) |
Modifier and Type | Method and Description |
---|---|
JsonNode |
fromInputStream(InputStream in)
Read a JSON value from an
InputStream |
JsonNode |
fromReader(Reader r)
Read a JSON value from a
Reader |
public JsonNodeReader(ObjectMapper mapper)
public JsonNodeReader()
public JsonNode fromInputStream(InputStream in) throws IOException
InputStream
in
- the input streamIOException
- malformed input, or problem encountered when reading
from the streampublic JsonNode fromReader(Reader r) throws IOException
Reader
r
- the readerIOException
- malformed input, or problem encountered when reading
from the reader