public class JSONReader extends Object
ValueReaders), but does not handle
any of reading itself (despite name).
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 reading;
instead, per-call instance is created by calling
perOperationInstance(int, com.fasterxml.jackson.jr.ob.impl.ValueReaderLocator, com.fasterxml.jackson.core.TreeCodec, com.fasterxml.jackson.core.JsonParser).
| Modifier and Type | Field and Description |
|---|---|
protected CollectionBuilder |
_collectionBuilder
Handler that takes care of constructing
Maps as needed |
protected int |
_features |
protected MapBuilder |
_mapBuilder
Handler that takes care of constructing
Maps as needed |
protected JsonParser |
_parser
Parser used by this reader instance.
|
protected ValueReaderLocator |
_readerLocator
Object that is used to find value readers dynamically.
|
protected Object[] |
_setterBuffer
Minor performance optimization:
Object[1] reused to avoid
Reflection having to allocate it for every "setter" call. |
protected TreeCodec |
_treeCodec
|
| Modifier | Constructor and Description |
|---|---|
|
JSONReader(CollectionBuilder lb,
MapBuilder mb)
Constructor used for creating the blueprint instances.
|
protected |
JSONReader(JSONReader base,
int features,
ValueReaderLocator loc,
TreeCodec tc,
JsonParser p)
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 JSONReader |
_with(CollectionBuilder lb,
MapBuilder mb)
Overridable method that all mutant factories call if a new instance
is to be constructed
|
boolean |
arraysAsLists() |
int |
features() |
boolean |
isEnabled(JSON.Feature f) |
JSONReader |
perOperationInstance(int features,
ValueReaderLocator loc,
TreeCodec tc,
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, binding values into specified type. |
Map<String,Object> |
readMap()
Method for reading a JSON Object from input and building a
Map
out of it. |
<T> Map<String,T> |
readMapOf(Class<T> type)
Method for reading a JSON Object from input and building a
Map
out of it, binding values into specified type. |
TreeNode |
readTree() |
Object |
readValue()
|
JSONReader |
with(CollectionBuilder lb) |
JSONReader |
with(MapBuilder mb) |
JSONReader |
withCacheCheck(int features) |
protected final MapBuilder _mapBuilder
Maps as neededprotected final CollectionBuilder _collectionBuilder
Maps as neededprotected final int _features
protected final TreeCodec _treeCodec
protected final ValueReaderLocator _readerLocator
protected final JsonParser _parser
protected final Object[] _setterBuffer
Object[1] reused to avoid
Reflection having to allocate it for every "setter" call.public JSONReader(CollectionBuilder lb, MapBuilder mb)
protected JSONReader(JSONReader base, int features, ValueReaderLocator loc, TreeCodec tc, JsonParser p)
public JSONReader withCacheCheck(int features)
public JSONReader with(MapBuilder mb)
public JSONReader with(CollectionBuilder lb)
protected JSONReader _with(CollectionBuilder lb, MapBuilder mb)
public JSONReader perOperationInstance(int features, ValueReaderLocator loc, TreeCodec tc, JsonParser p)
public boolean arraysAsLists()
public boolean isEnabled(JSON.Feature f)
public int features()
public 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.IOExceptionpublic Map<String,Object> readMap() throws IOException
Map
out of it. Note that if input does NOT contain a
JSON Object, JSONObjectException will be thrown.IOExceptionpublic List<Object> readList() throws IOException
List
out of it. Note that if input does NOT contain a
JSON Array, JSONObjectException will be thrown.IOExceptionpublic Object[] readArray() throws IOException
Object[]
out of it. Note that if input does NOT contain a
JSON Array, JSONObjectException will be thrown.IOExceptionpublic <T> T readBean(Class<T> type) throws IOException
IOExceptionpublic <T> T[] readArrayOf(Class<T> type) throws IOException
IOExceptionpublic <T> List<T> readListOf(Class<T> type) throws IOException
List
out of it, binding values into specified type.
Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.IOExceptionpublic <T> Map<String,T> readMapOf(Class<T> type) throws IOException
Map
out of it, binding values into specified type.
Note that if input does NOT contain a JSON Object, JSONObjectException will be thrown.IOExceptionpublic TreeNode readTree() throws IOException
IOExceptionprotected MapBuilder _mapBuilder(Class<?> mapType)
protected CollectionBuilder _collectionBuilder(Class<?> collType)
Copyright © 2024 FasterXML. All rights reserved.