com.github.fge.jackson
Class JsonNodeReader

java.lang.Object
  extended by com.github.fge.jackson.JsonNodeReader

@ThreadSafe
public final class JsonNodeReader
extends Object

Class dedicated to reading JSON values from InputStreams and Readers

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.

Since:
1.6
See Also:
ObjectMapper.readValues(JsonParser, Class)

Constructor Summary
JsonNodeReader()
          No-arg constructor (see description)
JsonNodeReader(ObjectMapper mapper)
           
 
Method Summary
 JsonNode fromInputStream(InputStream in)
          Read a JSON value from an InputStream
 JsonNode fromReader(Reader r)
          Read a JSON value from a Reader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonNodeReader

public JsonNodeReader(ObjectMapper mapper)

JsonNodeReader

public JsonNodeReader()
No-arg constructor (see description)

Method Detail

fromInputStream

public JsonNode fromInputStream(InputStream in)
                         throws IOException
Read a JSON value from an InputStream

Parameters:
in - the input stream
Returns:
the value
Throws:
IOException - malformed input, or problem encountered when reading from the stream

fromReader

public JsonNode fromReader(Reader r)
                    throws IOException
Read a JSON value from a Reader

Parameters:
r - the reader
Returns:
the value
Throws:
IOException - malformed input, or problem encountered when reading from the reader