Top Description Constructors Methods
com.fasterxml.jackson.core

public abstract Class ObjectCodec

extends TreeCodec
implements Versioned
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.Versioned
Imports
java.io.IOException, java.util.Iterator, com.fasterxml.jackson.core.type.ResolvedType, .TypeReference

Abstract class that defines the interface that JsonParser and JsonGenerator use to serialize and deserialize regular Java objects (POJOs aka Beans).

The standard implementation of this class is com.fasterxml.jackson.databind.ObjectMapper, defined in the "jackson-databind".

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract TreeNode

Returns:

Array node created
createArrayNode
()

Implements abstract com.fasterxml.jackson.core.TreeCodec.createArrayNode.

Method for construct root level Array nodes for Tree Model instances.

public abstract TreeNode

Returns:

Object node created
createObjectNode
()

Implements abstract com.fasterxml.jackson.core.TreeCodec.createObjectNode.

Method for construct root level Object nodes for Tree Model instances.

public JsonFactory

Returns:

Underlying JsonFactory instance
getFactory
()

Accessor for finding underlying data format factory (JsonFactory) codec will use for data binding.

public JsonFactory

Returns:

Underlying JsonFactory instance
getJsonFactory
()
Deprecated Use getFactory instead.

public abstract <T extends TreeNode> T

Returns:

next tree from p, or null if empty.
readTree
(JsonParser p)

Implements abstract com.fasterxml.jackson.core.TreeCodec.readTree.

Method for deserializing JSON content as tree expressed using set of TreeNode instances.

public abstract <
Nominal parameter for target type
T
>
T

Returns:

Value deserialized
readValue
(JsonParser
Parser to use for decoding content to bind
p
,
Class<T>
Java value type to bind content to
valueType
)

Method to deserialize JSON content into a non-container type (it can be an array type, however): typically a bean, array or a wrapper type (like java.lang.Boolean).

public abstract <
Nominal parameter for target type
T
>
T

Returns:

Value deserialized
readValue
(JsonParser
Parser to use for decoding content to bind
p
,
TypeReference<T>
Java value type to bind content to
valueTypeRef
)

Method to deserialize JSON content into a Java type, reference to which is passed as argument.

public abstract <
Nominal parameter for target type
T
>
T

Returns:

Value deserialized
readValue
(JsonParser
Parser to use for decoding content to bind
p
,
ResolvedType
Java value type to bind content to
valueType
)

Method to deserialize JSON content into a POJO, type specified with fully resolved type object (so it can be a generic type, including containers like java.util.Collection and java.util.Map).

public abstract <
Nominal parameter for target type
T
>
Iterator<T>

Returns:

Iterator for incrementally deserializing values
readValues
(JsonParser
Parser to use for decoding content to bind
p
,
Class<T>
Java value type to bind content to
valueType
)

Method for reading sequence of Objects from parser stream, all with same specified value type.

public abstract <
Nominal parameter for target type
T
>
Iterator<T>

Returns:

Iterator for incrementally deserializing values
readValues
(JsonParser
Parser to use for decoding content to bind
p
,
TypeReference<T>
Java value type to bind content to
valueTypeRef
)

Method for reading sequence of Objects from parser stream, all with same specified value type.

public abstract <
Nominal parameter for target type
T
>
Iterator<T>

Returns:

Iterator for incrementally deserializing values
readValues
(JsonParser
Parser to use for decoding content to bind
p
,
ResolvedType
Java value type to bind content to
valueType
)

Method for reading sequence of Objects from parser stream, all with same specified value type.

public abstract JsonParser

Returns:

Parser constructed for traversing over contents of specified node
treeAsTokens
(TreeNode
Content to traverse over
n
)

Implements abstract com.fasterxml.jackson.core.TreeCodec.treeAsTokens.

Method for constructing a JsonParser for reading contents of a JSON tree, as if it was external serialized JSON content.

public abstract <
Nominal parameter for target type
T
>
T

Returns:

Converted value instance
treeToValue
(TreeNode
Tree to convert
n
,
Class<T>
Java target value type to convert content to
valueType
)

Convenience method for converting given JSON tree into instance of specified value type.

public abstract Version
version()

Redeclares com.fasterxml.jackson.core.Versioned.version.

Method called to detect version of the component that implements this interface; returned version should never be null, but may return specific "not available" instance (see Version for details).

public abstract void
writeTree(JsonGenerator
Generator to use for serializing value
gen
,
TreeNode
Tree to serialize
tree
)

Implements abstract com.fasterxml.jackson.core.TreeCodec.writeTree.

Method for serializing JSON content from given Tree instance, using specified generator.

public abstract void
writeValue(JsonGenerator
Generator to use for serializing value
gen
,
Object
Value to serialize
value
)

Method to serialize given Java Object, using generator provided.

Inherited from com.fasterxml.jackson.core.TreeCodec:
missingNodenullNode

Constructor Detail

ObjectCodecback to summary
protected ObjectCodec()

Method Detail

createArrayNodeback to summary
public abstract TreeNode createArrayNode()

Implements abstract com.fasterxml.jackson.core.TreeCodec.createArrayNode.

Method for construct root level Array nodes for Tree Model instances.

Returns:TreeNode

Array node created

Annotations
@Override
createObjectNodeback to summary
public abstract TreeNode createObjectNode()

Implements abstract com.fasterxml.jackson.core.TreeCodec.createObjectNode.

Method for construct root level Object nodes for Tree Model instances.

Returns:TreeNode

Object node created

Annotations
@Override
getFactoryback to summary
public JsonFactory getFactory()

Accessor for finding underlying data format factory (JsonFactory) codec will use for data binding.

Returns:JsonFactory

Underlying JsonFactory instance

getJsonFactoryback to summary
public JsonFactory getJsonFactory()

Deprecated

Use getFactory instead.

Returns:JsonFactory

Underlying JsonFactory instance

Annotations
@Deprecated
readTreeback to summary
public abstract <T extends TreeNode> T readTree(JsonParser p) throws IOException

Implements abstract com.fasterxml.jackson.core.TreeCodec.readTree.

Method for deserializing JSON content as tree expressed using set of TreeNode instances. Returns root of the resulting tree (where root can consist of just a single node if the current event is a value event, not container). Empty or whitespace documents return null.

Returns:T

next tree from p, or null if empty.

Annotations
@Override
Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
readValueback to summary
public abstract <T> T readValue(JsonParser p, Class<T> valueType) throws IOException

Method to deserialize JSON content into a non-container type (it can be an array type, however): typically a bean, array or a wrapper type (like java.lang.Boolean).

Note

this method should NOT be used if the result type is a container (java.util.Collection or java.util.Map. The reason is that due to type erasure, key and value types can not be introspected when using this method.

Parameters
<T>
Nominal parameter for target type
p:JsonParser

Parser to use for decoding content to bind

valueType:Class<T>

Java value type to bind content to

Returns:T

Value deserialized

Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
readValueback to summary
public abstract <T> T readValue(JsonParser p, TypeReference<T> valueTypeRef) throws IOException

Method to deserialize JSON content into a Java type, reference to which is passed as argument. Type is passed using so-called "super type token" and specifically needs to be used if the root type is a parameterized (generic) container type.

Parameters
<T>
Nominal parameter for target type
p:JsonParser

Parser to use for decoding content to bind

valueTypeRef:TypeReference<T>

Java value type to bind content to

Returns:T

Value deserialized

Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
readValueback to summary
public abstract <T> T readValue(JsonParser p, ResolvedType valueType) throws IOException

Method to deserialize JSON content into a POJO, type specified with fully resolved type object (so it can be a generic type, including containers like java.util.Collection and java.util.Map).

Parameters
<T>
Nominal parameter for target type
p:JsonParser

Parser to use for decoding content to bind

valueType:ResolvedType

Java value type to bind content to

Returns:T

Value deserialized

Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
readValuesback to summary
public abstract <T> Iterator<T> readValues(JsonParser p, Class<T> valueType) throws IOException

Method for reading sequence of Objects from parser stream, all with same specified value type.

Parameters
<T>
Nominal parameter for target type
p:JsonParser

Parser to use for decoding content to bind

valueType:Class<T>

Java value type to bind content to

Returns:Iterator<T>

Iterator for incrementally deserializing values

Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
readValuesback to summary
public abstract <T> Iterator<T> readValues(JsonParser p, TypeReference<T> valueTypeRef) throws IOException

Method for reading sequence of Objects from parser stream, all with same specified value type.

Parameters
<T>
Nominal parameter for target type
p:JsonParser

Parser to use for decoding content to bind

valueTypeRef:TypeReference<T>

Java value type to bind content to

Returns:Iterator<T>

Iterator for incrementally deserializing values

Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
readValuesback to summary
public abstract <T> Iterator<T> readValues(JsonParser p, ResolvedType valueType) throws IOException

Method for reading sequence of Objects from parser stream, all with same specified value type.

Parameters
<T>
Nominal parameter for target type
p:JsonParser

Parser to use for decoding content to bind

valueType:ResolvedType

Java value type to bind content to

Returns:Iterator<T>

Iterator for incrementally deserializing values

Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
treeAsTokensback to summary
public abstract JsonParser treeAsTokens(TreeNode n)

Implements abstract com.fasterxml.jackson.core.TreeCodec.treeAsTokens.

Method for constructing a JsonParser for reading contents of a JSON tree, as if it was external serialized JSON content.

Parameters
n:TreeNode

Content to traverse over

Returns:JsonParser

Parser constructed for traversing over contents of specified node

Annotations
@Override
treeToValueback to summary
public abstract <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException

Convenience method for converting given JSON tree into instance of specified value type. This is equivalent to first constructing a JsonParser to iterate over contents of the tree, and using that parser for data binding.

Parameters
<T>
Nominal parameter for target type
n:TreeNode

Tree to convert

valueType:Class<T>

Java target value type to convert content to

Returns:T

Converted value instance

Exceptions
JsonProcessingException:
if structural conversion fails
versionback to summary
public abstract Version version()

Redeclares com.fasterxml.jackson.core.Versioned.version.

Doc from com.fasterxml.jackson.core.Versioned.version.

Method called to detect version of the component that implements this interface; returned version should never be null, but may return specific "not available" instance (see Version for details).

Returns:Version

Version of the component

Annotations
@Override
writeTreeback to summary
public abstract void writeTree(JsonGenerator gen, TreeNode tree) throws IOException

Implements abstract com.fasterxml.jackson.core.TreeCodec.writeTree.

Method for serializing JSON content from given Tree instance, using specified generator.

Parameters
gen:JsonGenerator

Generator to use for serializing value

tree:TreeNode

Tree to serialize

Annotations
@Override
Exceptions
IOException:
for low-level write issues, or JsonGenerationException for decoding problems
writeValueback to summary
public abstract void writeValue(JsonGenerator gen, Object value) throws IOException

Method to serialize given Java Object, using generator provided.

Parameters
gen:JsonGenerator

Generator to use for serializing value

value:Object

Value to serialize

Exceptions
IOException:
for low-level write issues, or JsonGenerationException for decoding problems