Package com.fasterxml.jackson.jr.ob.impl
Class JSONReader
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.impl.ValueReader
-
- com.fasterxml.jackson.jr.ob.impl.JSONReader
-
public class JSONReader extends ValueReader
Object that handles construction of simple Objects from JSON.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(int, com.fasterxml.jackson.core.JsonParser)
.
-
-
Field Summary
Fields Modifier and Type Field Description protected CollectionBuilder
_collectionBuilder
Handler that takes care of constructingMap
s as neededprotected int
_features
protected MapBuilder
_mapBuilder
Handler that takes care of constructingMap
s as neededprotected com.fasterxml.jackson.core.JsonParser
_parser
protected com.fasterxml.jackson.core.TreeCodec
_treeCodec
protected TypeDetector
_typeDetector
Object that is used to resolve types of values dynamically.
-
Constructor Summary
Constructors Modifier Constructor Description JSONReader(int features, TypeDetector td, com.fasterxml.jackson.core.TreeCodec treeCodec, CollectionBuilder lb, MapBuilder mb)
Constructor used for creating the blueprint instances.protected
JSONReader(JSONReader base, int features, TypeDetector td, com.fasterxml.jackson.core.JsonParser p)
Constructor used for per-operation (non-blueprint) instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CollectionBuilder
_collectionBuilder(Class<?> collType)
protected MapBuilder
_mapBuilder(Class<?> mapType)
protected com.fasterxml.jackson.core.TreeCodec
_treeCodec()
protected JSONReader
_with(int features, TypeDetector td, com.fasterxml.jackson.core.TreeCodec tc, CollectionBuilder lb, MapBuilder mb)
Overridable method that all mutant factories call if a new instance is to be constructedboolean
arraysAsLists()
JSONReader
perOperationInstance(int features, com.fasterxml.jackson.core.JsonParser p)
Object
read(JSONReader reader, com.fasterxml.jackson.core.JsonParser p)
Object[]
readArray()
Method for reading a JSON Array from input and building aObject[]
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 aList
out of it.<T> List<T>
readListOf(Class<T> type)
Method for reading a JSON Array from input and building aList
out of it.Map<Object,Object>
readMap()
Method for reading a JSON Object from input and building aMap
out of it.Object
readNext(JSONReader reader, com.fasterxml.jackson.core.JsonParser p)
Object
readValue()
JSONReader
with(CollectionBuilder lb)
JSONReader
with(MapBuilder mb)
JSONReader
withFeatures(int features)
-
Methods inherited from class com.fasterxml.jackson.jr.ob.impl.ValueReader
_tokenDesc, _tokenDesc
-
-
-
-
Field Detail
-
_features
protected final int _features
-
_treeCodec
protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
-
_typeDetector
protected final TypeDetector _typeDetector
Object that is used to resolve types of values dynamically.
-
_mapBuilder
protected final MapBuilder _mapBuilder
Handler that takes care of constructingMap
s as needed
-
_collectionBuilder
protected final CollectionBuilder _collectionBuilder
Handler that takes care of constructingMap
s as needed
-
_parser
protected final com.fasterxml.jackson.core.JsonParser _parser
-
-
Constructor Detail
-
JSONReader
public JSONReader(int features, TypeDetector td, com.fasterxml.jackson.core.TreeCodec treeCodec, CollectionBuilder lb, MapBuilder mb)
Constructor used for creating the blueprint instances.
-
JSONReader
protected JSONReader(JSONReader base, int features, TypeDetector td, com.fasterxml.jackson.core.JsonParser p)
Constructor used for per-operation (non-blueprint) instance.
-
-
Method Detail
-
read
public Object read(JSONReader reader, com.fasterxml.jackson.core.JsonParser p) throws IOException
- Specified by:
read
in classValueReader
- Throws:
IOException
-
readNext
public Object readNext(JSONReader reader, com.fasterxml.jackson.core.JsonParser p) throws IOException
- Specified by:
readNext
in classValueReader
- Throws:
IOException
-
withFeatures
public JSONReader withFeatures(int features)
-
with
public JSONReader with(MapBuilder mb)
-
with
public JSONReader with(CollectionBuilder lb)
-
_with
protected JSONReader _with(int features, TypeDetector td, com.fasterxml.jackson.core.TreeCodec tc, CollectionBuilder lb, MapBuilder mb)
Overridable method that all mutant factories call if a new instance is to be constructed
-
perOperationInstance
public JSONReader perOperationInstance(int features, com.fasterxml.jackson.core.JsonParser p)
-
arraysAsLists
public boolean arraysAsLists()
- Since:
- 2.8
-
readValue
public Object readValue() throws IOException
Method for reading a "simple" Object of type indicated by JSON content:Map
for JSON Object,Map
for JSON Array (or,Object[]
if so configured),String
for JSON String value and so on.- Throws:
IOException
-
readMap
public Map<Object,Object> readMap() throws IOException
Method for reading a JSON Object from input and building aMap
out of it. Note that if input does NOT contain a JSON Object,JSONObjectException
will be thrown.- Throws:
IOException
-
readList
public List<Object> readList() throws IOException
Method for reading a JSON Array from input and building aList
out of it. Note that if input does NOT contain a JSON Array,JSONObjectException
will be thrown.- Throws:
IOException
-
readArray
public Object[] readArray() throws IOException
Method for reading a JSON Array from input and building aObject[]
out of it. Note that if input does NOT contain a JSON Array,JSONObjectException
will be thrown.- Throws:
IOException
-
readBean
public <T> T readBean(Class<T> type) throws IOException
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.- Throws:
IOException
-
readArrayOf
public <T> T[] readArrayOf(Class<T> type) throws IOException
- Throws:
IOException
-
readListOf
public <T> List<T> readListOf(Class<T> type) throws IOException
Method for reading a JSON Array from input and building aList
out of it. Note that if input does NOT contain a JSON Array,JSONObjectException
will be thrown.- Throws:
IOException
-
_treeCodec
protected com.fasterxml.jackson.core.TreeCodec _treeCodec() throws JSONObjectException
- Throws:
JSONObjectException
-
_mapBuilder
protected MapBuilder _mapBuilder(Class<?> mapType)
-
_collectionBuilder
protected CollectionBuilder _collectionBuilder(Class<?> collType)
-
-