Uses "mutant factory" pattern so that instances are immutable
(and thus fully thread-safe with no external synchronization);
new instances are constructed for different configurations.
Instances are initially constructed by ObjectMapper
and can be
reused, shared, cached; both because of thread-safety and because
instances are relatively light-weight.
NOTE: this class is NOT meant as sub-classable by users. It is left as non-final mostly to allow frameworks that require byte code generation for proxying and similar use cases, but there is no expectation that functionality should be extended by sub-classing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DeserializationConfig
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary.protected final DeserializationContexts
Blueprint instance of deserialization context; used for creating actual instance when needed.protected final InjectableValues
Values that can be injected during deserialization, if any.protected final TokenStreamFactory
Factory used for constructingJsonParser
sprotected final ValueDeserializer<Object>
We may pre-fetch deserializer as soon as_valueType
is known, and if so, reuse it afterwards.protected final ConcurrentHashMap<JavaType,
ValueDeserializer<Object>> Root-level cached deserializers.protected final FormatSchema
When using data format that uses a schema, schema is passed to parser.protected final boolean
Flag that indicates whether root values are expected to be unwrapped or notprotected final Object
Instance to update with data binding; if any.protected final JavaType
Declared type of value to instantiate during deserialization.protected static final JavaType
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ObjectReader
(ObjectMapper mapper, DeserializationConfig config) Constructor used byObjectMapper
for initial instantiationprotected
ObjectReader
(ObjectMapper mapper, DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) Constructor called when a root deserializer should be fetched based on other configuration.protected
ObjectReader
(ObjectReader base, TokenFilter filter) protected
ObjectReader
(ObjectReader base, DeserializationConfig config) Copy constructor used when modifying simple feature flagsprotected
ObjectReader
(ObjectReader base, DeserializationConfig config, JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) Copy constructor used for building variations. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
_assertNotNull
(String paramName, Object src) protected Object
_bind
(DeserializationContextExt ctxt, JsonParser p, Object valueToUpdate) Actual implementation of value reading+binding operation.protected Object
_bindAndClose
(DeserializationContextExt ctxt, JsonParser p0) protected final JsonNode
protected <T> MappingIterator<T>
protected final JsonNode
protected final JsonNode
Same as_bindAsTree(tools.jackson.databind.deser.DeserializationContextExt, tools.jackson.core.JsonParser)
except end-of-input is reported by returningnull
, not "missing node"protected JsonParser
_considerFilter
(JsonParser p, boolean multiValue) Consider filter when creating JsonParser.protected DeserializationContextExt
Internal helper method called to create an instance ofDeserializationContext
for deserializing a single root value.protected DeserializationContextExt
protected ValueDeserializer<Object>
Method called to locate deserializer for the passed root-level value.protected ValueDeserializer<Object>
protected void
Alternative to_initForReading(tools.jackson.databind.deser.DeserializationContextExt, tools.jackson.core.JsonParser)
used in cases where reading of multiple values means that we may or may not want to advance the stream, but need to do other initialization.protected JsonToken
protected InputStream
_inputStream
(File f) protected InputStream
_inputStream
(URL src) protected InputStream
_inputStream
(Path path) protected ObjectReader
_new
(ObjectReader base, DeserializationConfig config) Factory method called by various "withXxx()" methodsprotected ObjectReader
_new
(ObjectReader base, DeserializationConfig config, JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) Factory method called by various "withXxx()" methodsprotected <T> MappingIterator<T>
_newIterator
(JsonParser p, DeserializationContext ctxt, ValueDeserializer<?> deser, boolean parserManaged) Factory method used to createMappingIterator
instances; either default, or custom subtype.protected ValueDeserializer<Object>
_prefetchRootDeserializer
(JavaType valueType) Method called to locate deserializer ahead of time, if permitted by configuration.protected final void
_verifyNoTrailingTokens
(JsonParser p, DeserializationContext ctxt, JavaType bindType) protected void
_verifySchemaType
(FormatSchema schema) protected final ObjectReader
_with
(DeserializationConfig newConfig) Convenience method to bind fromJsonPointer
.at
(JsonPointer pointer) Convenience method to bind fromJsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later.booleanNode
(boolean b) Factory method for constructing non-blockingJsonParser
that is properly wired to allow configuration access (and, if relevant for parser, callbacks): essentially constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,DataInput)
.createParser
(byte[] content) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,byte[])
.createParser
(byte[] content, int offset, int len) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,byte[],int,int)
.createParser
(char[] content) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,char[])
.createParser
(char[] content, int offset, int len) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,char[],int,int)
.createParser
(DataInput content) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,DataInput)
.createParser
(File src) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,java.io.File)
.createParser
(InputStream src) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,InputStream)
.createParser
(Reader src) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,Reader)
.createParser
(String content) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,String)
.createParser
(URL src) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,java.net.URL)
.createParser
(Path src) Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,Path)
.Method for constructing a new reader instance that is configured to data bind into specified type.forType
(TypeReference<?> valueTypeRef) Method for constructing a new reader instance that is configured to data bind into specified type.Method for constructing a new reader instance that is configured to data bind into specified type.Deprecated.boolean
boolean
boolean
boolean
nullNode()
readTree
(byte[] content) Same asreadTree(InputStream)
except content read from passed-in byte array.readTree
(byte[] content, int offset, int len) Same asreadTree(InputStream)
except content read from passed-in byte array.Same asreadTree(InputStream)
except content read using passed-inDataInput
.readTree
(InputStream src) Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree.Same asreadTree(InputStream)
except content accessed through passed-inReader
Same asreadTree(InputStream)
except content read from passed-inString
Convenience method that binds content read using given parser, using configuration of this reader, except that content is bound as JSON tree instead of configured root value type.<T> T
readValue
(byte[] content) Method that binds content read from given byte array, using configuration of this reader.<T> T
readValue
(byte[] buffer, int offset, int length) Method that binds content read from given byte array, using configuration of this reader.<T> T
<T> T
Method that binds content read from givenFile
using configuration of this reader.<T> T
readValue
(InputStream in) Method that binds content read from given input source, using configuration of this reader.<T> T
Method that binds content read from given input source, using configuration of this reader.<T> T
Method that binds content read from given JSON string, using configuration of this reader.<T> T
Method that binds content read from given input source, using configuration of this reader.<T> T
Method that binds content read from givenPath
using configuration of this reader.<T> T
Method that binds content read using given parser, using configuration of this reader, including expected result type.<T> T
Convenience method for converting results from given JSON tree into given value type.final <T> MappingIterator<T>
readValues
(byte[] content) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(byte[] content, int offset, int length) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(DataInput src) <T> MappingIterator<T>
readValues
(File src) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(InputStream src) Method for reading sequence of Objects from parser stream.<T> MappingIterator<T>
readValues
(Reader src) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(String content) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(URL src) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(Path src) Overloaded version ofreadValues(InputStream)
.<T> MappingIterator<T>
Method for reading sequence of Objects from parser stream.<T> Iterator<T>
readValues
(JsonParser p, Class<T> valueType) Convenience method that is equivalent to:<T> Iterator<T>
readValues
(JsonParser p, ResolvedType valueType) Convenience method that is equivalent to:<T> Iterator<T>
readValues
(JsonParser p, TypeReference<T> valueTypeRef) Convenience method that is equivalent to:<T> Iterator<T>
readValues
(JsonParser p, JavaType valueType) Convenience method that is equivalent to:stringNode
(String text) protected JsonParser
treeAsTokens
(JsonNode n, DeserializationContext ctxt) <T> T
treeToValue
(TreeNode n, Class<T> valueType) <T> T
treeToValue
(TreeNode n, JavaType valueType) Same astreeToValue(TreeNode, Class)
but with type-resolved target value type.version()
Method that will return version information stored in and read from jar that contains this class.with
(Base64Variant defaultBase64) with
(FormatFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(FormatSchema schema) Method for constructing a new instance with configuration that passes specifiedFormatSchema
toJsonParser
that is constructed for parsing content.with
(StreamReadFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(ContextAttributes attrs) Mutant factory for overriding set of (default) attributes forObjectReader
to use.with
(DatatypeFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(DeserializationConfig config) Mutant factory method that will construct a new instance that has specified underlyingDeserializationConfig
.with
(DeserializationFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(DeserializationFeature first, DeserializationFeature... other) Method for constructing a new reader instance that is configured with specified features enabled.with
(InjectableValues injectableValues) Method for constructing a new instance with configuration that uses passedInjectableValues
to provide injectable values.Method for constructing a new reader instance with configuration that uses passedJsonNodeFactory
for constructingJsonNode
instances.withAttribute
(Object key, Object value) withAttributes
(Map<?, ?> attrs) withFeatures
(FormatFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFeatures
(StreamReadFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFeatures
(DatatypeFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFeatures
(DeserializationFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.without
(FormatFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(StreamReadFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(DatatypeFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(DeserializationFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(DeserializationFeature first, DeserializationFeature... other) Method for constructing a new reader instance that is configured with specified features disabled.withoutAttribute
(Object key) withoutFeatures
(FormatFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.withoutFeatures
(StreamReadFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.withoutFeatures
(DatatypeFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.withoutFeatures
(DeserializationFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectReader
.withRootName
(String rootName) Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping".withRootName
(PropertyName rootName) withValueToUpdate
(Object value) Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.Method for constructing a new instance with configuration that uses specified View for filtering.void
writeTree
(JsonGenerator g, TreeNode tree)
-
Field Details
-
JSON_NODE_TYPE
-
_config
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary. -
_contexts
Blueprint instance of deserialization context; used for creating actual instance when needed. -
_parserFactory
Factory used for constructingJsonParser
s -
_unwrapRoot
protected final boolean _unwrapRootFlag that indicates whether root values are expected to be unwrapped or not -
_valueType
Declared type of value to instantiate during deserialization. Defines which deserializer to use; as well as base type of instance to construct if an updatable value is not configured to be used (subject to changes by embedded type information, for polymorphic types). If_valueToUpdate
is non-null, only used for locating deserializer. -
_rootDeserializer
We may pre-fetch deserializer as soon as_valueType
is known, and if so, reuse it afterwards. This allows avoiding further deserializer lookups and increases performance a bit on cases where readers are reused. -
_valueToUpdate
Instance to update with data binding; if any. If null, a new instance is created, if non-null, properties of this value object will be updated instead. Note that value can be of almost any type, except notArrayType
; array types cannot be modified because array size is immutable. -
_schema
When using data format that uses a schema, schema is passed to parser. -
_injectableValues
Values that can be injected during deserialization, if any. -
_rootDeserializers
Root-level cached deserializers. Passed byObjectMapper
, shared with it.
-
-
Constructor Details
-
ObjectReader
Constructor used byObjectMapper
for initial instantiation -
ObjectReader
protected ObjectReader(ObjectMapper mapper, DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) Constructor called when a root deserializer should be fetched based on other configuration. -
ObjectReader
protected ObjectReader(ObjectReader base, DeserializationConfig config, JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) Copy constructor used for building variations. -
ObjectReader
Copy constructor used when modifying simple feature flags -
ObjectReader
-
-
Method Details
-
version
Method that will return version information stored in and read from jar that contains this class. -
_new
Factory method called by various "withXxx()" methods -
_new
protected ObjectReader _new(ObjectReader base, DeserializationConfig config, JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) Factory method called by various "withXxx()" methods -
_newIterator
protected <T> MappingIterator<T> _newIterator(JsonParser p, DeserializationContext ctxt, ValueDeserializer<?> deser, boolean parserManaged) Factory method used to createMappingIterator
instances; either default, or custom subtype. -
_initForReading
-
_initForMultiRead
Alternative to_initForReading(tools.jackson.databind.deser.DeserializationContextExt, tools.jackson.core.JsonParser)
used in cases where reading of multiple values means that we may or may not want to advance the stream, but need to do other initialization.Base implementation only sets configured
FormatSchema
, if any, on parser. -
with
Method for constructing a new reader instance that is configured with specified feature enabled. -
with
Method for constructing a new reader instance that is configured with specified features enabled. -
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled. -
without
Method for constructing a new reader instance that is configured with specified feature disabled. -
without
Method for constructing a new reader instance that is configured with specified features disabled. -
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled. -
with
Method for constructing a new reader instance that is configured with specified feature enabled. -
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled. -
without
Method for constructing a new reader instance that is configured with specified feature disabled. -
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled. -
with
Method for constructing a new reader instance that is configured with specified feature enabled. -
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled. -
without
Method for constructing a new reader instance that is configured with specified feature disabled. -
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled. -
with
Method for constructing a new reader instance that is configured with specified feature enabled. -
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled. -
without
Method for constructing a new reader instance that is configured with specified feature disabled. -
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled. -
at
Convenience method to bind fromJsonPointer
.JsonPointerBasedFilter
is registered and will be used for parsing later. -
at
Convenience method to bind fromJsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later. -
with
Mutant factory method that will construct a new instance that has specified underlyingDeserializationConfig
.NOTE: use of this method is not recommended, as there are many other re-configuration methods available.
-
with
Method for constructing a new instance with configuration that uses passedInjectableValues
to provide injectable values.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
with
Method for constructing a new reader instance with configuration that uses passedJsonNodeFactory
for constructingJsonNode
instances.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withRootName
Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping". SeeMapperConfigBase.withRootName(String)
for details.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withRootName
-
withoutRootName
Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectReader
. -
with
Method for constructing a new instance with configuration that passes specifiedFormatSchema
toJsonParser
that is constructed for parsing content.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
forType
Method for constructing a new reader instance that is configured to data bind into specified type.Note that the method does not change state of this reader, but rather construct and returns a newly configured instance.
-
forType
Method for constructing a new reader instance that is configured to data bind into specified type.Note that the method does not change state of this reader, but rather construct and returns a newly configured instance.
-
forType
Method for constructing a new reader instance that is configured to data bind into specified type.Note that the method does not change state of this reader, but rather construct and returns a newly configured instance.
-
withValueToUpdate
Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withView
Method for constructing a new instance with configuration that uses specified View for filtering.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
with
-
with
-
withHandler
-
with
-
with
Mutant factory for overriding set of (default) attributes forObjectReader
to use.Note that this will replace defaults passed by
ObjectMapper
.- Parameters:
attrs
- DefaultContextAttributes
to use with a reader- Returns:
ObjectReader
instance with specified default attributes (which is usually a newly constructed reader instance with otherwise identical settings)
-
withAttributes
-
withAttribute
-
withoutAttribute
-
_with
-
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
-
getConfig
-
parserFactory
- Since:
- 3.0
-
typeFactory
- Since:
- 3.0
-
getAttributes
-
getInjectableValues
-
getValueType
-
getTypeFactory
Deprecated.Since 3.0 usetypeFactory()
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,java.io.File)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,Path)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,java.net.URL)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,InputStream)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,Reader)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,byte[])
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,byte[],int,int)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,String)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,char[])
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,char[],int,int)
.- Throws:
JacksonException
- Since:
- 3.0
-
createParser
Factory method for constructingJsonParser
that is properly wired to allow callbacks for deserialization: basically constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,DataInput)
.- Throws:
JacksonException
- Since:
- 3.0
-
createNonBlockingByteArrayParser
Factory method for constructing non-blockingJsonParser
that is properly wired to allow configuration access (and, if relevant for parser, callbacks): essentially constructs aObjectReadContext
and then callsTokenStreamFactory.createParser(ObjectReadContext,DataInput)
.- Throws:
JacksonException
- Since:
- 3.0
-
createObjectNode
- Specified by:
createObjectNode
in interfaceTreeCodec
-
createArrayNode
- Specified by:
createArrayNode
in interfaceTreeCodec
-
booleanNode
- Specified by:
booleanNode
in interfaceTreeCodec
-
stringNode
- Specified by:
stringNode
in interfaceTreeCodec
-
missingNode
- Specified by:
missingNode
in interfaceTreeCodec
-
nullNode
-
treeAsTokens
- Specified by:
treeAsTokens
in interfaceTreeCodec
-
treeAsTokens
-
readTree
Convenience method that binds content read using given parser, using configuration of this reader, except that content is bound as JSON tree instead of configured root value type. ReturnsJsonNode
that represents the root of the resulting tree, if there was content to read, ornull
if no more content is accessible via passedJsonParser
.NOTE! Behavior with end-of-input (no more content) differs between this
readTree
method, and all other methods that take input source: latter will return "missing node", NOTnull
Note: if an object was specified with
withValueToUpdate(java.lang.Object)
, it will be ignored.- Specified by:
readTree
in interfaceTreeCodec
- Throws:
JacksonException
-
writeTree
-
readValue
Method that binds content read using given parser, using configuration of this reader, including expected result type. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Throws:
JacksonException
-
readValues
Convenience method that is equivalent to:withType(valueType).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.- Throws:
JacksonException
-
readValues
public <T> Iterator<T> readValues(JsonParser p, TypeReference<T> valueTypeRef) throws JacksonException Convenience method that is equivalent to:withType(valueTypeRef).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.- Throws:
JacksonException
-
readValues
Convenience method that is equivalent to:withType(valueType).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.- Throws:
JacksonException
-
readValues
Convenience method that is equivalent to:withType(valueType).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.- Throws:
JacksonException
-
readValue
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Throws:
JacksonException
-
readValue
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
r
- Source to read content from- Throws:
JacksonException
-
readValue
Method that binds content read from given JSON string, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
content
- String that contains content to read- Throws:
JacksonException
-
readValue
Method that binds content read from given byte array, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
content
- Byte array that contains encoded content to read- Throws:
JacksonException
-
readValue
Method that binds content read from given byte array, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
buffer
- Byte array that contains encoded content to readoffset
- Offset of the first content byte inbuffer
length
- Length of content inbuffer
, in bytes- Throws:
JacksonException
-
readValue
Method that binds content read from givenFile
using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
f
- File that contains content to read- Throws:
JacksonException
-
readValue
Method that binds content read from givenPath
using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
path
- Path that contains content to read- Throws:
JacksonException
- Since:
- 3.0
-
readValue
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.NOTE: handling of
URL
is delegated toTokenStreamFactory.createParser(ObjectReadContext, java.net.URL)
and usually simply callsURL.openStream()
, meaning no special handling is done. If different HTTP connection options are needed you will need to createInputStream
separately.- Throws:
JacksonException
-
readValue
Convenience method for converting results from given JSON tree into given value type. Basically short-cut for:objectReader.readValue(src.traverse())
- Parameters:
node
- Tree that contains content to convert- Throws:
JacksonException
-
readValue
- Throws:
JacksonException
-
readTree
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree. ReturnsJsonNode
that represents the root of the resulting tree, if there was content to read, or "missing node" (instance ofJsonNode
for whichJsonNode.isMissingNode()
returns true, and behaves otherwise similar to "null node") if no more content is accessible through passed-in input source.NOTE! Behavior with end-of-input (no more content) differs between this
readTree
method, andreadTree(JsonParser)
-- latter returnsnull
for "no content" case.Note that if an object was specified with a call to
withValueToUpdate(Object)
it will just be ignored; result is always a newly constructedJsonNode
instance.- Throws:
JacksonException
-
readTree
Same asreadTree(InputStream)
except content accessed through passed-inReader
- Throws:
JacksonException
-
readTree
Same asreadTree(InputStream)
except content read from passed-inString
- Throws:
JacksonException
-
readTree
Same asreadTree(InputStream)
except content read from passed-in byte array.- Throws:
JacksonException
-
readTree
Same asreadTree(InputStream)
except content read from passed-in byte array.- Throws:
JacksonException
-
readTree
Same asreadTree(InputStream)
except content read using passed-inDataInput
.- Throws:
JacksonException
-
readValues
Method for reading sequence of Objects from parser stream.Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
must point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
but rather to the token following it.- Throws:
JacksonException
-
readValues
Method for reading sequence of Objects from parser stream.Sequence can be either wrapped or unwrapped root-level sequence: wrapped means that the elements are enclosed in JSON Array; and unwrapped that elements are directly accessed at main level. Assumption is that iff the first token of the document is
START_ARRAY
, we have a wrapped sequence; otherwise unwrapped. For wrapped sequences, leadingSTART_ARRAY
is skipped, so that for both cases, underlyingJsonParser
will point to what is expected to be the first token of the first element.Note that the wrapped vs unwrapped logic means that it is NOT possible to use this method for reading an unwrapped sequence of elements written as JSON Arrays: to read such sequences, one has to use
readValues(JsonParser)
, making sure parser points to the first token of the first element (i.e. the secondSTART_ARRAY
which is part of the first element).- Throws:
JacksonException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
JacksonException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Parameters:
content
- String that contains JSON content to parse- Throws:
JacksonException
-
readValues
public <T> MappingIterator<T> readValues(byte[] content, int offset, int length) throws JacksonException Overloaded version ofreadValue(InputStream)
.- Throws:
JacksonException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
JacksonException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
JacksonException
-
readValues
Overloaded version ofreadValues(InputStream)
.- Throws:
JacksonException
- Since:
- 3.0
-
readValues
Overloaded version ofreadValue(InputStream)
.NOTE: handling of
URL
is delegated toTokenStreamFactory.createParser(ObjectReadContext, java.net.URL)
and usually simply callsURL.openStream()
, meaning no special handling is done. If different HTTP connection options are needed you will need to createInputStream
separately.- Parameters:
src
- URL to read to access JSON content to parse.- Throws:
JacksonException
-
readValues
- Throws:
JacksonException
-
treeToValue
- Throws:
JacksonException
-
treeToValue
Same astreeToValue(TreeNode, Class)
but with type-resolved target value type.- Throws:
JacksonException
-
_bind
protected Object _bind(DeserializationContextExt ctxt, JsonParser p, Object valueToUpdate) throws JacksonException Actual implementation of value reading+binding operation.- Throws:
JacksonException
-
_bindAndClose
protected Object _bindAndClose(DeserializationContextExt ctxt, JsonParser p0) throws JacksonException - Throws:
JacksonException
-
_bindAndCloseAsTree
protected final JsonNode _bindAndCloseAsTree(DeserializationContextExt ctxt, JsonParser p0) throws JacksonException - Throws:
JacksonException
-
_bindAsTree
protected final JsonNode _bindAsTree(DeserializationContextExt ctxt, JsonParser p) throws JacksonException - Throws:
JacksonException
-
_bindAsTreeOrNull
protected final JsonNode _bindAsTreeOrNull(DeserializationContextExt ctxt, JsonParser p) throws JacksonException Same as_bindAsTree(tools.jackson.databind.deser.DeserializationContextExt, tools.jackson.core.JsonParser)
except end-of-input is reported by returningnull
, not "missing node"- Throws:
JacksonException
-
_bindAndReadValues
protected <T> MappingIterator<T> _bindAndReadValues(DeserializationContextExt ctxt, JsonParser p) throws JacksonException - Throws:
JacksonException
-
_considerFilter
Consider filter when creating JsonParser. -
_verifyNoTrailingTokens
protected final void _verifyNoTrailingTokens(JsonParser p, DeserializationContext ctxt, JavaType bindType) throws JacksonException - Throws:
JacksonException
-
_verifySchemaType
-
_deserializationContext
Internal helper method called to create an instance ofDeserializationContext
for deserializing a single root value. Can be overridden if a custom context is needed. -
_deserializationContext
-
_inputStream
- Throws:
JacksonException
-
_inputStream
- Throws:
JacksonException
-
_inputStream
- Throws:
JacksonException
-
_assertNotNull
-
_findRootDeserializer
protected ValueDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt) throws DatabindException Method called to locate deserializer for the passed root-level value.- Throws:
DatabindException
-
_findTreeDeserializer
protected ValueDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt) throws DatabindException - Throws:
DatabindException
-
_prefetchRootDeserializer
Method called to locate deserializer ahead of time, if permitted by configuration. Method also is NOT to throw an exception if access fails.
-
typeFactory()