public class ObjectReader extends ObjectCodec implements Versioned, java.io.Serializable
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 (with Jackson 2.8 and above) by users. It is left as non-final mostly to allow frameworks that require bytecode generation for proxying and similar use cases, but there is no expecation that functionality should be extended by sub-classing.
Modifier and Type | Method and Description |
---|---|
ObjectReader |
at(JsonPointer pointer)
Convenience method to bind from
JsonPointer
JsonPointerBasedFilter is registered and will be used for parsing later. |
ObjectReader |
at(java.lang.String pointerExpr)
Convenience method to bind from
JsonPointer . |
JsonNode |
createArrayNode()
Method for construct root level Array nodes
for Tree Model instances.
|
JsonParser |
createNonBlockingByteArrayParser()
Factory method for constructing properly initialized
JsonParser
to read content using non-blocking (asynchronous) mode. |
JsonNode |
createObjectNode()
Method for construct root level Object nodes
for Tree Model instances.
|
JsonParser |
createParser(byte[] content)
Factory method for constructing properly initialized
JsonParser
to read content from specified byte array. |
JsonParser |
createParser(byte[] content,
int offset,
int len)
Factory method for constructing properly initialized
JsonParser
to read content from specified byte array. |
JsonParser |
createParser(char[] content)
Factory method for constructing properly initialized
JsonParser
to read content from specified character array
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete. |
JsonParser |
createParser(char[] content,
int offset,
int len)
Factory method for constructing properly initialized
JsonParser
to read content from specified character array. |
JsonParser |
createParser(java.io.DataInput content)
Factory method for constructing properly initialized
JsonParser
to read content using specified DataInput . |
JsonParser |
createParser(java.io.File src)
Factory method for constructing properly initialized
JsonParser
to read content from specified File . |
JsonParser |
createParser(java.io.InputStream in)
Factory method for constructing properly initialized
JsonParser
to read content using specified InputStream . |
JsonParser |
createParser(java.io.Reader r)
Factory method for constructing properly initialized
JsonParser
to read content using specified Reader . |
JsonParser |
createParser(java.lang.String content)
Factory method for constructing properly initialized
JsonParser
to read content from specified String. |
JsonParser |
createParser(java.net.URL src)
Factory method for constructing properly initialized
JsonParser
to read content from specified File . |
ObjectReader |
forType(java.lang.Class<?> valueType)
Method for constructing a new reader instance that is configured
to data bind into specified type.
|
ObjectReader |
forType(JavaType valueType)
Method for constructing a new reader instance that is configured
to data bind into specified type.
|
ObjectReader |
forType(TypeReference<?> valueTypeRef)
Method for constructing a new reader instance that is configured
to data bind into specified type.
|
ContextAttributes |
getAttributes() |
DeserializationConfig |
getConfig() |
JsonFactory |
getFactory()
Accessor for finding underlying data format factory
(
JsonFactory ) codec will use for data binding. |
InjectableValues |
getInjectableValues() |
TypeFactory |
getTypeFactory() |
JavaType |
getValueType() |
boolean |
isEnabled(DeserializationFeature f) |
boolean |
isEnabled(JsonParser.Feature f) |
boolean |
isEnabled(MapperFeature f) |
boolean |
isEnabled(StreamReadFeature f) |
JsonNode |
missingNode() |
JsonNode |
nullNode() |
JsonNode |
readTree(byte[] json)
Same as
readTree(InputStream) except content read from
passed-in byte array. |
JsonNode |
readTree(byte[] json,
int offset,
int len)
Same as
readTree(InputStream) except content read from
passed-in byte array. |
JsonNode |
readTree(java.io.DataInput src)
Same as
readTree(InputStream) except content read using
passed-in DataInput . |
JsonNode |
readTree(java.io.InputStream src)
Method that reads content from given input source,
using configuration of this reader, and binds it as JSON Tree.
|
<T extends TreeNode> |
readTree(JsonParser p)
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.
|
JsonNode |
readTree(java.io.Reader src)
Same as
readTree(InputStream) except content accessed through
passed-in Reader |
JsonNode |
readTree(java.lang.String json)
Same as
readTree(InputStream) except content read from
passed-in String |
<T> T |
readValue(byte[] content)
Method that binds content read from given byte array,
using configuration of this reader.
|
<T> T |
readValue(byte[] content,
java.lang.Class<T> valueType)
Same as
readValue(byte[]) except that target value type
overridden as valueType |
<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 |
readValue(byte[] buffer,
int offset,
int length,
java.lang.Class<T> valueType)
Same as
readValue(byte[],int,int) except that target value type
overridden as valueType |
<T> T |
readValue(java.io.DataInput src) |
<T> T |
readValue(java.io.DataInput content,
java.lang.Class<T> valueType)
Same as
readValue(DataInput) except that target value type
overridden as valueType |
<T> T |
readValue(java.io.File src)
Method that binds content read from given
File
using configuration of this reader. |
<T> T |
readValue(java.io.File src,
java.lang.Class<T> valueType)
Same as
readValue(File) except that target value type
overridden as valueType |
<T> T |
readValue(java.io.InputStream src)
Method that binds content read from given input source,
using configuration of this reader.
|
<T> T |
readValue(java.io.InputStream src,
java.lang.Class<T> valueType)
Same as
readValue(InputStream) except that target value type
overridden as valueType |
<T> T |
readValue(JsonNode content)
Convenience method for converting results from given JSON tree into given
value type.
|
<T> T |
readValue(JsonNode content,
java.lang.Class<T> valueType)
Same as
readValue(JsonNode) except that target value type
overridden as valueType |
<T> T |
readValue(JsonParser p)
Method that binds content read using given parser, using
configuration of this reader, including expected result type.
|
<T> T |
readValue(JsonParser p,
java.lang.Class<T> valueType)
Convenience method that binds content read using given parser, using
configuration of this reader, except that expected value type
is specified with the call (instead of currently configured root type).
|
<T> T |
readValue(JsonParser p,
JavaType valueType)
Type-safe overloaded method, basically alias for
readValue(JsonParser, ResolvedType) . |
<T> T |
readValue(JsonParser p,
ResolvedType valueType)
Convenience method that binds content read using given parser, using
configuration of this reader, except that expected value type
is specified with the call (instead of currently configured root type).
|
<T> T |
readValue(JsonParser p,
TypeReference<T> valueTypeRef)
Convenience method that binds content read using given parser, using
configuration of this reader, except that expected value type
is specified with the call (instead of currently configured root type).
|
<T> T |
readValue(java.io.Reader src)
Method that binds content read from given input source,
using configuration of this reader.
|
<T> T |
readValue(java.io.Reader src,
java.lang.Class<T> valueType)
Same as
readValue(Reader) except that target value type
overridden as valueType |
<T> T |
readValue(java.lang.String src)
Method that binds content read from given JSON string,
using configuration of this reader.
|
<T> T |
readValue(java.lang.String src,
java.lang.Class<T> valueType)
Same as
readValue(String) except that target value type
overridden as valueType |
<T> T |
readValue(java.net.URL src)
Method that binds content read from given input source,
using configuration of this reader.
|
<T> T |
readValue(java.net.URL src,
java.lang.Class<T> valueType)
Same as
readValue(URL) except that target value type
overridden as valueType |
<T> MappingIterator<T> |
readValues(byte[] src)
Overloaded version of
readValue(InputStream) . |
<T> MappingIterator<T> |
readValues(byte[] src,
int offset,
int length)
Overloaded version of
readValue(InputStream) . |
<T> MappingIterator<T> |
readValues(java.io.DataInput src) |
<T> MappingIterator<T> |
readValues(java.io.File src)
Overloaded version of
readValue(InputStream) . |
<T> MappingIterator<T> |
readValues(java.io.InputStream src)
Method for reading sequence of Objects from parser stream.
|
<T> MappingIterator<T> |
readValues(JsonParser p)
Method for reading sequence of Objects from parser stream.
|
<T> java.util.Iterator<T> |
readValues(JsonParser p,
java.lang.Class<T> valueType)
Convenience method that is equivalent to:
|
<T> java.util.Iterator<T> |
readValues(JsonParser p,
JavaType valueType)
Convenience method that is equivalent to:
|
<T> java.util.Iterator<T> |
readValues(JsonParser p,
ResolvedType valueType)
Convenience method that is equivalent to:
|
<T> java.util.Iterator<T> |
readValues(JsonParser p,
TypeReference<T> valueTypeRef)
Convenience method that is equivalent to:
|
<T> MappingIterator<T> |
readValues(java.io.Reader src)
Overloaded version of
readValue(InputStream) . |
<T> MappingIterator<T> |
readValues(java.lang.String json)
Overloaded version of
readValue(InputStream) . |
<T> MappingIterator<T> |
readValues(java.net.URL src)
Overloaded version of
readValue(InputStream) . |
JsonParser |
treeAsTokens(TreeNode n)
Method for constructing a
JsonParser for reading
contents of a JSON tree, as if it was external serialized
JSON content. |
<T> T |
treeToValue(TreeNode n,
java.lang.Class<T> valueType)
Convenience method for converting given JSON tree into instance of specified
value type.
|
<T> T |
treeToValue(TreeNode n,
JavaType valueType)
Same as
treeToValue(TreeNode, Class) but with type-resolved target value type. |
Version |
version()
Method that will return version information stored in and read from jar
that contains this class.
|
ObjectReader |
with(Base64Variant defaultBase64) |
ObjectReader |
with(ContextAttributes attrs) |
ObjectReader |
with(DeserializationConfig config)
Mutant factory method that will construct a new instance that has
specified underlying
DeserializationConfig . |
ObjectReader |
with(DeserializationFeature feature)
Method for constructing a new reader instance that is configured
with specified feature enabled.
|
ObjectReader |
with(DeserializationFeature first,
DeserializationFeature... other)
Method for constructing a new reader instance that is configured
with specified features enabled.
|
ObjectReader |
with(FormatFeature feature)
Method for constructing a new reader instance that is configured
with specified feature enabled.
|
ObjectReader |
with(FormatSchema schema)
Method for constructing a new instance with configuration that
passes specified
FormatSchema to JsonParser that
is constructed for parsing content. |
ObjectReader |
with(InjectableValues injectableValues)
Method for constructing a new instance with configuration that uses
passed
InjectableValues to provide injectable values. |
ObjectReader |
with(JsonFactory f)
Method for constructing a new reader instance with configuration that uses
passed
JsonFactory for constructing underlying Readers. |
ObjectReader |
with(JsonNodeFactory f)
Method for constructing a new reader instance with configuration that uses
passed
JsonNodeFactory for constructing JsonNode
instances. |
ObjectReader |
with(JsonParser.Feature feature)
Method for constructing a new reader instance that is configured
with specified feature enabled.
|
ObjectReader |
with(java.util.Locale l) |
ObjectReader |
with(StreamReadFeature feature)
Method for constructing a new reader instance that is configured
with specified feature enabled.
|
ObjectReader |
with(java.util.TimeZone tz) |
ObjectReader |
withAttribute(java.lang.Object key,
java.lang.Object value) |
ObjectReader |
withAttributes(java.util.Map<?,?> attrs) |
ObjectReader |
withFeatures(DeserializationFeature... features)
Method for constructing a new reader instance that is configured
with specified features enabled.
|
ObjectReader |
withFeatures(FormatFeature... features)
Method for constructing a new reader instance that is configured
with specified features enabled.
|
ObjectReader |
withFeatures(JsonParser.Feature... features)
Method for constructing a new reader instance that is configured
with specified features enabled.
|
ObjectReader |
withFormatDetection(DataFormatReaders readers)
Fluent factory method for constructing a reader that will try to
auto-detect underlying data format, using specified
DataFormatReaders . |
ObjectReader |
withFormatDetection(ObjectReader... readers)
Fluent factory method for constructing a reader that will try to
auto-detect underlying data format, using specified list of
JsonFactory instances, and default DataFormatReaders settings
(for customized DataFormatReaders , you can construct instance yourself). |
ObjectReader |
withHandler(DeserializationProblemHandler h) |
ObjectReader |
without(DeserializationFeature feature)
Method for constructing a new reader instance that is configured
with specified feature disabled.
|
ObjectReader |
without(DeserializationFeature first,
DeserializationFeature... other)
Method for constructing a new reader instance that is configured
with specified features disabled.
|
ObjectReader |
without(FormatFeature feature)
Method for constructing a new reader instance that is configured
with specified feature disabled.
|
ObjectReader |
without(JsonParser.Feature feature)
Method for constructing a new reader instance that is configured
with specified feature disabled.
|
ObjectReader |
without(StreamReadFeature feature)
Method for constructing a new reader instance that is configured
with specified feature disabled.
|
ObjectReader |
withoutAttribute(java.lang.Object key) |
ObjectReader |
withoutFeatures(DeserializationFeature... features)
Method for constructing a new reader instance that is configured
with specified features disabled.
|
ObjectReader |
withoutFeatures(FormatFeature... features)
Method for constructing a new reader instance that is configured
with specified features disabled.
|
ObjectReader |
withoutFeatures(JsonParser.Feature... features)
Method for constructing a new reader instance that is configured
with specified features disabled.
|
ObjectReader |
withoutRootName()
Convenience method that is same as calling:
withRootName("")
which will forcibly prevent use of root name wrapping when writing
values with this ObjectReader . |
ObjectReader |
withRootName(PropertyName rootName) |
ObjectReader |
withRootName(java.lang.String rootName)
Method for constructing a new instance with configuration that
specifies what root name to expect for "root name unwrapping".
|
ObjectReader |
withType(java.lang.Class<?> valueType)
Deprecated.
since 2.5 Use
forType(Class) instead |
ObjectReader |
withType(JavaType valueType)
Deprecated.
since 2.5 Use
forType(JavaType) instead |
ObjectReader |
withType(java.lang.reflect.Type valueType)
Deprecated.
since 2.5 Use
forType(Class) instead |
ObjectReader |
withType(TypeReference<?> valueTypeRef)
Deprecated.
since 2.5 Use
forType(TypeReference) instead |
ObjectReader |
withValueToUpdate(java.lang.Object value)
Method for constructing a new instance with configuration that
updates passed Object (as root value), instead of constructing
a new value.
|
ObjectReader |
withView(java.lang.Class<?> activeView)
Method for constructing a new instance with configuration that
uses specified View for filtering.
|
void |
writeTree(JsonGenerator g,
TreeNode rootNode)
Method for serializing JSON content from given Tree instance, using
specified generator.
|
void |
writeValue(JsonGenerator gen,
java.lang.Object value)
Method to serialize given Java Object, using generator
provided.
|
getJsonFactory
public Version version()
version
in interface Versioned
version
in class ObjectCodec
public ObjectReader with(DeserializationFeature feature)
public ObjectReader with(DeserializationFeature first, DeserializationFeature... other)
public ObjectReader withFeatures(DeserializationFeature... features)
public ObjectReader without(DeserializationFeature feature)
public ObjectReader without(DeserializationFeature first, DeserializationFeature... other)
public ObjectReader withoutFeatures(DeserializationFeature... features)
public ObjectReader with(JsonParser.Feature feature)
feature
- Feature to enablepublic ObjectReader withFeatures(JsonParser.Feature... features)
features
- Features to enablepublic ObjectReader without(JsonParser.Feature feature)
feature
- Feature to disablepublic ObjectReader withoutFeatures(JsonParser.Feature... features)
features
- Features to disablepublic ObjectReader with(StreamReadFeature feature)
public ObjectReader without(StreamReadFeature feature)
public ObjectReader with(FormatFeature feature)
public ObjectReader withFeatures(FormatFeature... features)
public ObjectReader without(FormatFeature feature)
public ObjectReader withoutFeatures(FormatFeature... features)
public ObjectReader at(java.lang.String pointerExpr)
JsonPointer
.
JsonPointerBasedFilter
is registered and will be used for parsing later.public ObjectReader at(JsonPointer pointer)
JsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later.public ObjectReader with(DeserializationConfig config)
DeserializationConfig
.
NOTE: use of this method is not recommended, as there are many other re-configuration methods available.
public ObjectReader with(InjectableValues injectableValues)
InjectableValues
to provide injectable values.
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader with(JsonNodeFactory f)
JsonNodeFactory
for constructing JsonNode
instances.
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader with(JsonFactory f)
JsonFactory
for constructing underlying Readers.
NOTE: only factories that DO NOT REQUIRE SPECIAL MAPPERS
(that is, ones that return false
for
JsonFactory.requiresCustomCodec()
) can be used: trying
to use one that requires custom codec will throw exception
public ObjectReader withRootName(java.lang.String rootName)
MapperConfigBase.withRootName(String)
for
details.
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withRootName(PropertyName rootName)
public ObjectReader withoutRootName()
withRootName("")
which will forcibly prevent use of root name wrapping when writing
values with this ObjectReader
.public ObjectReader with(FormatSchema schema)
FormatSchema
to JsonParser
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.
public ObjectReader forType(JavaType valueType)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader forType(java.lang.Class<?> valueType)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader forType(TypeReference<?> valueTypeRef)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
@Deprecated public ObjectReader withType(JavaType valueType)
forType(JavaType)
instead@Deprecated public ObjectReader withType(java.lang.Class<?> valueType)
forType(Class)
instead@Deprecated public ObjectReader withType(java.lang.reflect.Type valueType)
forType(Class)
instead@Deprecated public ObjectReader withType(TypeReference<?> valueTypeRef)
forType(TypeReference)
insteadpublic ObjectReader withValueToUpdate(java.lang.Object value)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withView(java.lang.Class<?> activeView)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader with(java.util.Locale l)
public ObjectReader with(java.util.TimeZone tz)
public ObjectReader withHandler(DeserializationProblemHandler h)
public ObjectReader with(Base64Variant defaultBase64)
public ObjectReader withFormatDetection(ObjectReader... readers)
JsonFactory
instances, and default DataFormatReaders
settings
(for customized DataFormatReaders
, you can construct instance yourself).
to construct appropriate JsonParser
for actual parsing.
Note: since format detection only works with byte sources, it is possible to get a failure from some 'readValue()' methods. Also, if input cannot be reliably (enough) detected as one of specified types, an exception will be thrown.
Note: not all JsonFactory
types can be passed: specifically, ones that
require "custom codec" (like XML factory) will not work. Instead, use
method that takes ObjectReader
instances instead of factories.
readers
- Data formats accepted, in decreasing order of priority (that is,
matches checked in listed order, first match wins)public ObjectReader withFormatDetection(DataFormatReaders readers)
DataFormatReaders
.
NOTE: since format detection only works with byte sources, it is possible to get a failure from some 'readValue()' methods. Also, if input cannot be reliably (enough) detected as one of specified types, an exception will be thrown.
readers
- DataFormatReaders to use for detecting underlying format.public ObjectReader with(ContextAttributes attrs)
public ObjectReader withAttributes(java.util.Map<?,?> attrs)
public ObjectReader withAttribute(java.lang.Object key, java.lang.Object value)
public ObjectReader withoutAttribute(java.lang.Object key)
public boolean isEnabled(DeserializationFeature f)
public boolean isEnabled(MapperFeature f)
public boolean isEnabled(JsonParser.Feature f)
public boolean isEnabled(StreamReadFeature f)
public DeserializationConfig getConfig()
public JsonFactory getFactory()
ObjectCodec
JsonFactory
) codec will use for data binding.getFactory
in class ObjectCodec
JsonFactory
instancepublic TypeFactory getTypeFactory()
public ContextAttributes getAttributes()
public InjectableValues getInjectableValues()
public JavaType getValueType()
public JsonParser createParser(java.io.File src) throws java.io.IOException
JsonParser
to read content from specified File
.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(java.net.URL src) throws java.io.IOException
JsonParser
to read content from specified File
.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(java.io.InputStream in) throws java.io.IOException
JsonParser
to read content using specified InputStream
.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(java.io.Reader r) throws java.io.IOException
JsonParser
to read content using specified Reader
.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(byte[] content) throws java.io.IOException
JsonParser
to read content from specified byte array.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(byte[] content, int offset, int len) throws java.io.IOException
JsonParser
to read content from specified byte array.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(java.lang.String content) throws java.io.IOException
JsonParser
to read content from specified String.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(char[] content) throws java.io.IOException
JsonParser
to read content from specified character array
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(char[] content, int offset, int len) throws java.io.IOException
JsonParser
to read content from specified character array.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createParser(java.io.DataInput content) throws java.io.IOException
JsonParser
to read content using specified DataInput
.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public JsonParser createNonBlockingByteArrayParser() throws java.io.IOException
JsonParser
to read content using non-blocking (asynchronous) mode.
Parser is not managed (or "owned") by ObjectReader: caller is responsible
for properly closing it once content reading is complete.java.io.IOException
public <T> T readValue(JsonParser p) throws java.io.IOException
withValueToUpdate(Object)
.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
java.io.IOException
public <T> T readValue(JsonParser p, java.lang.Class<T> valueType) throws java.io.IOException
withValueToUpdate(Object)
.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readValue
in class ObjectCodec
T
- Nominal parameter for target typep
- Parser to use for decoding content to bindvalueType
- Java value type to bind content tojava.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic <T> T readValue(JsonParser p, TypeReference<T> valueTypeRef) throws java.io.IOException
withValueToUpdate(Object)
.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readValue
in class ObjectCodec
T
- Nominal parameter for target typep
- Parser to use for decoding content to bindvalueTypeRef
- Java value type to bind content tojava.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic <T> T readValue(JsonParser p, ResolvedType valueType) throws java.io.IOException
withValueToUpdate(Object)
.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readValue
in class ObjectCodec
T
- Nominal parameter for target typep
- Parser to use for decoding content to bindvalueType
- Java value type to bind content tojava.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic <T> T readValue(JsonParser p, JavaType valueType) throws java.io.IOException
readValue(JsonParser, ResolvedType)
.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
java.io.IOException
public <T> java.util.Iterator<T> readValues(JsonParser p, java.lang.Class<T> valueType) throws java.io.IOException
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 surrounding START_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.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readValues
in class ObjectCodec
T
- Nominal parameter for target typep
- Parser to use for decoding content to bindvalueType
- Java value type to bind content tojava.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic <T> java.util.Iterator<T> readValues(JsonParser p, TypeReference<T> valueTypeRef) throws java.io.IOException
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 surrounding START_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.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readValues
in class ObjectCodec
T
- Nominal parameter for target typep
- Parser to use for decoding content to bindvalueTypeRef
- Java value type to bind content tojava.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic <T> java.util.Iterator<T> readValues(JsonParser p, ResolvedType valueType) throws java.io.IOException
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 surrounding START_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.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readValues
in class ObjectCodec
T
- Nominal parameter for target typep
- Parser to use for decoding content to bindvalueType
- Java value type to bind content tojava.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic <T> java.util.Iterator<T> readValues(JsonParser p, JavaType valueType) throws java.io.IOException
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 surrounding START_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.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
java.io.IOException
public JsonNode createArrayNode()
ObjectCodec
createArrayNode
in class ObjectCodec
public JsonNode createObjectNode()
ObjectCodec
createObjectNode
in class ObjectCodec
public JsonNode missingNode()
missingNode
in class TreeCodec
public JsonNode nullNode()
public JsonParser treeAsTokens(TreeNode n)
ObjectCodec
JsonParser
for reading
contents of a JSON tree, as if it was external serialized
JSON content.treeAsTokens
in class ObjectCodec
n
- Content to traverse overpublic <T extends TreeNode> T readTree(JsonParser p) throws java.io.IOException
JsonNode
that represents the root of the resulting tree, if there
was content to read, or null
if no more content is accessible
via passed JsonParser
.
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", NOT null
Note: if an object was specified with withValueToUpdate(java.lang.Object)
, it
will be ignored.
NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
readTree
in class ObjectCodec
p
, or null
if empty.java.io.IOException
- for low-level read issues, or
JsonParseException
for decoding problemspublic void writeTree(JsonGenerator g, TreeNode rootNode)
ObjectCodec
writeTree
in class ObjectCodec
g
- Generator to use for serializing valuerootNode
- Tree to serializepublic <T> T readValue(java.io.InputStream src) throws java.io.IOException
withValueToUpdate(Object)
.src
- Source to read content fromjava.io.IOException
public <T> T readValue(java.io.InputStream src, java.lang.Class<T> valueType) throws java.io.IOException
readValue(InputStream)
except that target value type
overridden as valueType
src
- Source to read content fromvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(java.io.Reader src) throws java.io.IOException
withValueToUpdate(Object)
.src
- Source to read content fromjava.io.IOException
public <T> T readValue(java.io.Reader src, java.lang.Class<T> valueType) throws java.io.IOException
readValue(Reader)
except that target value type
overridden as valueType
src
- Source to read content fromvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(java.lang.String src) throws JsonProcessingException, JsonMappingException
withValueToUpdate(Object)
.src
- String that contains content to readJsonProcessingException
JsonMappingException
public <T> T readValue(java.lang.String src, java.lang.Class<T> valueType) throws java.io.IOException
readValue(String)
except that target value type
overridden as valueType
src
- String that contains content to readvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(byte[] content) throws java.io.IOException
withValueToUpdate(Object)
.content
- Byte array that contains encoded content to readjava.io.IOException
public <T> T readValue(byte[] content, java.lang.Class<T> valueType) throws java.io.IOException
readValue(byte[])
except that target value type
overridden as valueType
content
- Byte array that contains encoded content to readvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(byte[] buffer, int offset, int length) throws java.io.IOException
withValueToUpdate(Object)
.buffer
- Byte array that contains encoded content to readoffset
- Offset of the first content byte in buffer
length
- Length of content in buffer
, in bytesjava.io.IOException
public <T> T readValue(byte[] buffer, int offset, int length, java.lang.Class<T> valueType) throws java.io.IOException
readValue(byte[],int,int)
except that target value type
overridden as valueType
buffer
- Byte array that contains encoded content to readoffset
- Offset of the first content byte in buffer
length
- Length of content in buffer
, in bytesvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(java.io.File src) throws java.io.IOException
File
using configuration of this reader.
Value return is either newly constructed, or root value that
was specified with withValueToUpdate(Object)
.src
- File that contains content to readjava.io.IOException
public <T> T readValue(java.io.File src, java.lang.Class<T> valueType) throws java.io.IOException
readValue(File)
except that target value type
overridden as valueType
src
- File that contains content to readvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(java.net.URL src) throws java.io.IOException
withValueToUpdate(Object)
.
NOTE: handling of URL
is delegated to
JsonFactory.createParser(java.net.URL)
and usually simply
calls URL.openStream()
, meaning no special handling
is done. If different HTTP connection options are needed you will need
to create InputStream
separately.
java.io.IOException
public <T> T readValue(java.net.URL src, java.lang.Class<T> valueType) throws java.io.IOException
readValue(URL)
except that target value type
overridden as valueType
src
- URL pointing to resource that contains content to readvalueType
- Target type to bind content tojava.io.IOException
public <T> T readValue(JsonNode content) throws java.io.IOException
objectReader.readValue(src.traverse())
content
- Tree that contains content to convertjava.io.IOException
public <T> T readValue(JsonNode content, java.lang.Class<T> valueType) throws java.io.IOException
readValue(JsonNode)
except that target value type
overridden as valueType
content
- Tree that contains content to convertvalueType
- Target type to convert content tojava.io.IOException
public <T> T readValue(java.io.DataInput src) throws java.io.IOException
java.io.IOException
public <T> T readValue(java.io.DataInput content, java.lang.Class<T> valueType) throws java.io.IOException
readValue(DataInput)
except that target value type
overridden as valueType
content
- DataInput that contains content to readvalueType
- Target type to bind content tojava.io.IOException
public JsonNode readTree(java.io.InputStream src) throws java.io.IOException
JsonNode
that represents the root of the resulting tree, if there
was content to read, or "missing node" (instance of JsonNode
for which
JsonNode.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, and readTree(JsonParser)
-- latter returns
null
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 constructed
JsonNode
instance.
java.io.IOException
public JsonNode readTree(java.io.Reader src) throws java.io.IOException
readTree(InputStream)
except content accessed through
passed-in Reader
java.io.IOException
public JsonNode readTree(java.lang.String json) throws JsonProcessingException, JsonMappingException
readTree(InputStream)
except content read from
passed-in String
public JsonNode readTree(byte[] json) throws java.io.IOException
readTree(InputStream)
except content read from
passed-in byte array.java.io.IOException
public JsonNode readTree(byte[] json, int offset, int len) throws java.io.IOException
readTree(InputStream)
except content read from
passed-in byte array.java.io.IOException
public JsonNode readTree(java.io.DataInput src) throws java.io.IOException
readTree(InputStream)
except content read using
passed-in DataInput
.java.io.IOException
public <T> MappingIterator<T> readValues(JsonParser p) throws java.io.IOException
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 surrounding START_ARRAY
but rather
to the token following it.
java.io.IOException
public <T> MappingIterator<T> readValues(java.io.InputStream src) throws java.io.IOException
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, leading START_ARRAY
is skipped, so that for both cases, underlying JsonParser
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 second
START_ARRAY
which is part of the first element).
java.io.IOException
public <T> MappingIterator<T> readValues(java.io.Reader src) throws java.io.IOException
readValue(InputStream)
.java.io.IOException
public <T> MappingIterator<T> readValues(java.lang.String json) throws java.io.IOException
readValue(InputStream)
.json
- String that contains JSON content to parsejava.io.IOException
public <T> MappingIterator<T> readValues(byte[] src, int offset, int length) throws java.io.IOException
readValue(InputStream)
.java.io.IOException
public final <T> MappingIterator<T> readValues(byte[] src) throws java.io.IOException
readValue(InputStream)
.java.io.IOException
public <T> MappingIterator<T> readValues(java.io.File src) throws java.io.IOException
readValue(InputStream)
.java.io.IOException
public <T> MappingIterator<T> readValues(java.net.URL src) throws java.io.IOException
readValue(InputStream)
.
NOTE: handling of URL
is delegated to
JsonFactory.createParser(java.net.URL)
and usually simply
calls URL.openStream()
, meaning no special handling
is done. If different HTTP connection options are needed you will need
to create InputStream
separately.
src
- URL to read to access JSON content to parse.java.io.IOException
public <T> MappingIterator<T> readValues(java.io.DataInput src) throws java.io.IOException
java.io.IOException
public <T> T treeToValue(TreeNode n, java.lang.Class<T> valueType) throws JsonProcessingException
ObjectCodec
JsonParser
to
iterate over contents of the tree, and using that parser for data binding.treeToValue
in class ObjectCodec
T
- Nominal parameter for target typen
- Tree to convertvalueType
- Java target value type to convert content toJsonProcessingException
- if structural conversion failspublic <T> T treeToValue(TreeNode n, JavaType valueType) throws JsonProcessingException
treeToValue(TreeNode, Class)
but with type-resolved target value type.JsonProcessingException
public void writeValue(JsonGenerator gen, java.lang.Object value) throws java.io.IOException
ObjectCodec
writeValue
in class ObjectCodec
gen
- Generator to use for serializing valuevalue
- Value to serializejava.io.IOException
- for low-level write issues, or
JsonGenerationException
for decoding problemsCopyright © 2010 - 2023 Adobe. All Rights Reserved