Top Description Fields Constructors Methods
com.fasterxml.jackson.jr.ob.impl

public Class JSONAsObjectCodec

extends ObjectCodec
Class Inheritance
Imports
java.io.IOException, java.util.Iterator, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.type.ResolvedType, .TypeReference, com.fasterxml.jackson.jr.ob.JSON, .JSONObjectException, .PackageVersion

Convenience wrapper around JSON that implements ObjectCodec. Note that implementation is not complete, due to natural limitations of JSON and "simple" object binding.

The main use case is to give minimal context for other components that expect to get a ObjectCodec, such as JsonParser and JsonGenerator.

Field Summary

Modifier and TypeField and Description
protected final JSON
protected final JsonFactory
protected final TreeCodec

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
protected void
_checkResultType(Class<?> valueType, Object ob)

protected TreeCodec
protected JSONObjectException
public TreeNode
createArrayNode()

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

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

public TreeNode
createObjectNode()

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

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

public JsonFactory
getFactory()

Overrides com.fasterxml.jackson.core.ObjectCodec.getFactory.

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

public JsonFactory
public TreeNode
public TreeNode
public <T extends TreeNode> T
readTree(JsonParser jp)

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

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValue.

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 <T> T
readValue(JsonParser
Parser to use for decoding content to bind
p
,
TypeReference<T>
Java value type to bind content to
valueTypeRef
)

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValue.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValue.

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 <T> Iterator<T>
readValues(JsonParser
Parser to use for decoding content to bind
p
,
Class<T>
Java value type to bind content to
valueType
)

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValues.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValues.

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

public <T> Iterator<T>
readValues(JsonParser
Parser to use for decoding content to bind
p
,
ResolvedType
Java value type to bind content to
valueType
)

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValues.

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

public JsonParser
treeAsTokens(TreeNode
Content to traverse over
n
)

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

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.treeToValue.

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

public Version
version()

Implements abstract com.fasterxml.jackson.core.ObjectCodec.version.

Implements 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 void
writeTree(JsonGenerator
Generator to use for serializing value
jg
,
TreeNode
Tree to serialize
tree
)

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

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.writeValue.

Method to serialize given Java Object, using generator provided.

Field Detail

_jsonback to summary
protected final JSON _json
_jsonFactoryback to summary
protected final JsonFactory _jsonFactory
_treeCodecback to summary
protected final TreeCodec _treeCodec

Constructor Detail

JSONAsObjectCodecback to summary
public JSONAsObjectCodec(JSON json)
JSONAsObjectCodecback to summary
public JSONAsObjectCodec(JSON json, JsonFactory jf)
JSONAsObjectCodecback to summary
public JSONAsObjectCodec(JSON json, JsonFactory jf, TreeCodec treeCodec)

Method Detail

_checkResultTypeback to summary
protected void _checkResultType(Class<?> valueType, Object ob) throws JSONObjectException
_checkTreeCodecback to summary
protected TreeCodec _checkTreeCodec()
_noTypeReferenceback to summary
protected JSONObjectException _noTypeReference()
createArrayNodeback to summary
public TreeNode createArrayNode()

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

Doc from com.fasterxml.jackson.core.ObjectCodec.createArrayNode.

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

Returns:TreeNode

Array node created

Annotations
@Override
createObjectNodeback to summary
public TreeNode createObjectNode()

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

Doc from com.fasterxml.jackson.core.ObjectCodec.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()

Overrides com.fasterxml.jackson.core.ObjectCodec.getFactory.

Doc from com.fasterxml.jackson.core.ObjectCodec.getFactory.

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

Returns:JsonFactory

Underlying JsonFactory instance

Annotations
@Override
getJsonFactoryback to summary
public JsonFactory getJsonFactory()

Overrides com.fasterxml.jackson.core.ObjectCodec.getJsonFactory.

Deprecated

Returns:JsonFactory

Doc from com.fasterxml.jackson.core.ObjectCodec.getJsonFactory.

Underlying JsonFactory instance

Annotations
@Deprecated
@Override
missingNodeback to summary
public TreeNode missingNode()

Overrides com.fasterxml.jackson.core.TreeCodec.missingNode.

Returns:TreeNode

Doc from com.fasterxml.jackson.core.TreeCodec.missingNode.

Node that represents "missing" node during traversal: something referenced but that does not exist in content model

Annotations
@Override
nullNodeback to summary
public TreeNode nullNode()

Overrides com.fasterxml.jackson.core.TreeCodec.nullNode.

Returns:TreeNode

Doc from com.fasterxml.jackson.core.TreeCodec.nullNode.

Node that represents explicit null value in content

Annotations
@Override
readTreeback to summary
public <T extends TreeNode> T readTree(JsonParser jp) throws IOException, JsonProcessingException

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

Doc from com.fasterxml.jackson.core.ObjectCodec.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 <T> T readValue(JsonParser p, Class<T> valueType) throws IOException, JsonProcessingException

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValue.

Doc from com.fasterxml.jackson.core.ObjectCodec.readValue.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValue.

Doc from com.fasterxml.jackson.core.ObjectCodec.readValue.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValue.

Doc from com.fasterxml.jackson.core.ObjectCodec.readValue.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValues.

Doc from com.fasterxml.jackson.core.ObjectCodec.readValues.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValues.

Doc from com.fasterxml.jackson.core.ObjectCodec.readValues.

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

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

Implements abstract com.fasterxml.jackson.core.ObjectCodec.readValues.

Doc from com.fasterxml.jackson.core.ObjectCodec.readValues.

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

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

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

Doc from com.fasterxml.jackson.core.ObjectCodec.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 <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException

Implements abstract com.fasterxml.jackson.core.ObjectCodec.treeToValue.

Doc from com.fasterxml.jackson.core.ObjectCodec.treeToValue.

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

Annotations
@Override
Exceptions
JsonProcessingException:
if structural conversion fails
versionback to summary
public Version version()

Implements abstract com.fasterxml.jackson.core.ObjectCodec.version.

Implements 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 void writeTree(JsonGenerator jg, TreeNode tree) throws IOException, JsonProcessingException

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

Doc from com.fasterxml.jackson.core.ObjectCodec.writeTree.

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

Parameters
jg: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 void writeValue(JsonGenerator jgen, Object value) throws IOException, JsonProcessingException

Implements abstract com.fasterxml.jackson.core.ObjectCodec.writeValue.

Doc from com.fasterxml.jackson.core.ObjectCodec.writeValue.

Method to serialize given Java Object, using generator provided.

Parameters
jgen:JsonGenerator

Generator to use for serializing value

value:Object

Value to serialize

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