public class JSONReader extends ValueReader
Life-cycle is such that initial instance (called blueprint)
is constructed first (including possible configuration
using mutant factory methods). This blueprint object
acts as a factory, and is never used for direct writing;
instead, per-call instance is created by calling
perOperationInstance(com.fasterxml.jackson.core.JsonParser)
.
Modifier and Type | Field and Description |
---|---|
protected boolean |
_arraysAsLists |
protected CollectionBuilder |
_collectionBuilder
Handler that takes care of constructing
Map s as needed |
protected int |
_features |
protected MapBuilder |
_mapBuilder
Handler that takes care of constructing
Map s as needed |
protected JsonParser |
_parser |
protected TreeCodec |
_treeCodec |
protected TypeDetector |
_typeDetector
Object that is used to resolve types of values dynamically.
|
Modifier | Constructor and Description |
---|---|
|
JSONReader(int features,
TypeDetector td,
TreeCodec treeCodec,
CollectionBuilder lb,
MapBuilder mb)
Constructor used for creating the blueprint instances.
|
protected |
JSONReader(JSONReader base,
JsonParser jp)
Constructor used for per-operation (non-blueprint) instance.
|
Modifier and Type | Method and Description |
---|---|
protected CollectionBuilder |
_collectionBuilder(Class<?> collType) |
protected MapBuilder |
_mapBuilder(Class<?> mapType) |
protected TreeCodec |
_treeCodec() |
protected JSONReader |
_with(int features,
TypeDetector td,
TreeCodec tc,
CollectionBuilder lb,
MapBuilder mb)
Overridable method that all mutant factories call if a new instance
is to be constructed
|
JSONReader |
perOperationInstance(JsonParser jp) |
Object |
read(JSONReader reader,
JsonParser p) |
Object[] |
readArray()
Method for reading a JSON Array from input and building a
Object[]
out of it. |
<T> T[] |
readArrayOf(Class<T> type) |
<T> T |
readBean(Class<T> type)
Method for reading a JSON Object from input and building a Bean of
specified type out of it; Bean has to conform to standard Java Bean
specification by having setters for passing JSON Object properties.
|
List<Object> |
readList()
Method for reading a JSON Array from input and building a
List
out of it. |
<T> List<T> |
readListOf(Class<T> type)
Method for reading a JSON Array from input and building a
List
out of it. |
Map<Object,Object> |
readMap()
Method for reading a JSON Object from input and building a
Map
out of it. |
Object |
readValue()
|
JSONReader |
with(CollectionBuilder lb) |
JSONReader |
with(MapBuilder mb) |
JSONReader |
withFeatures(int features) |
_tokenDesc, _tokenDesc
protected final int _features
protected final boolean _arraysAsLists
protected final TreeCodec _treeCodec
protected final TypeDetector _typeDetector
protected final MapBuilder _mapBuilder
Map
s as neededprotected final CollectionBuilder _collectionBuilder
Map
s as neededprotected final JsonParser _parser
public JSONReader(int features, TypeDetector td, TreeCodec treeCodec, CollectionBuilder lb, MapBuilder mb)
protected JSONReader(JSONReader base, JsonParser jp)
public Object read(JSONReader reader, JsonParser p) throws IOException
read
in class ValueReader
IOException
public final JSONReader withFeatures(int features)
public final JSONReader with(MapBuilder mb)
public final JSONReader with(CollectionBuilder lb)
protected JSONReader _with(int features, TypeDetector td, TreeCodec tc, CollectionBuilder lb, MapBuilder mb)
public JSONReader perOperationInstance(JsonParser jp)
public final Object readValue() throws IOException
Map
for JSON Object, Map
for JSON Array (or, Object[]
if so configured),
String
for JSON String value and so on.IOException
public Map<Object,Object> readMap() throws IOException
Map
out of it. Note that if input does NOT contain a
JSON Object, JSONObjectException
will be thrown.IOException
public List<Object> readList() throws IOException
List
out of it. Note that if input does NOT contain a
JSON Array, JSONObjectException
will be thrown.IOException
public Object[] readArray() throws IOException, JsonProcessingException
Object[]
out of it. Note that if input does NOT contain a
JSON Array, JSONObjectException
will be thrown.IOException
JsonProcessingException
public <T> T readBean(Class<T> type) throws IOException, JsonProcessingException
IOException
JsonProcessingException
public <T> T[] readArrayOf(Class<T> type) throws IOException, JsonProcessingException
IOException
JsonProcessingException
public <T> List<T> readListOf(Class<T> type) throws IOException
List
out of it. Note that if input does NOT contain a
JSON Array, JSONObjectException
will be thrown.IOException
protected TreeCodec _treeCodec() throws JSONObjectException
JSONObjectException
protected MapBuilder _mapBuilder(Class<?> mapType)
protected CollectionBuilder _collectionBuilder(Class<?> collType)
Copyright © 2014-2015 FasterXML. All Rights Reserved.