Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.fasterxml.jackson.core
Class ObjectCodec

    java.lang.Object
      com.fasterxml.jackson.core.ObjectCodec

    public abstract class ObjectCodec

extends Object

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
`protected` | `ObjectCodec()`

Method Summary
`abstract TreeNode` | `createArrayNode()` Method for construct root level Array nodes for Tree Model instances.
`abstract TreeNode` | `createObjectNode()` Method for construct root level Object nodes for Tree Model instances.
`JsonFactory` | `getFactory()` Accessor for finding underlying data format factory (`JsonFactory`) codec will use for data binding.
`abstract JsonFactory` | `getJsonFactory()` Deprecated. Since 2.1: Use `getFactory()` instead.
`abstract
`<T extends TreeNode> T`
` | `readTree(JsonParser jp)` Method to deserialize JSON content as tree expressed using set of `TreeNode` instances.
`abstract
`<T> T`
` | `readValue(JsonParser jp, Class<T> 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 `Boolean`).
`abstract
`<T> T`
` | `readValue(JsonParser jp, ResolvedType 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 `Collection` and `Map`).
`abstract
`<T> T`
` | `readValue(JsonParser jp, TypeReference<?> valueTypeRef)` Method to deserialize JSON content into a Java type, reference to which is passed as argument.
`abstract
`<T> Iterator<T>`
` | `readValues(JsonParser jp, Class<T> valueType)` Method for reading sequence of Objects from parser stream, all with same specified value type.
`abstract
`<T> Iterator<T>`
` | `readValues(JsonParser jp, ResolvedType valueType)` Method for reading sequence of Objects from parser stream, all with same specified value type.
`abstract
`<T> Iterator<T>`
` | `readValues(JsonParser jp, TypeReference<?> valueTypeRef)` Method for reading sequence of Objects from parser stream, all with same specified value type.
`abstract JsonParser` | `treeAsTokens(TreeNode n)` Method for constructing a `JsonParser` for reading contents of a JSON tree, as if it was external serialized JSON content.
`abstract
`<T> T`
` | `treeToValue(TreeNode n, Class<T> valueType)` Convenience method for converting given JSON tree into instance of specified value type.
`abstract void` | `writeValue(JsonGenerator jgen, Object value)` Method to serialize given Java Object, using generator provided.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ObjectCodec

    protected ObjectCodec()

Method Detail

### readValue

    public abstract <T> T readValue(JsonParser jp,
                                    Class<T> valueType)
                         throws IOException,
                                JsonProcessingException

  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 `Boolean`).

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

  Throws:
    `IOException`
    `JsonProcessingException`

### readValue

    public abstract <T> T readValue(JsonParser jp,
                                    TypeReference<?> valueTypeRef)
                         throws IOException,
                                JsonProcessingException

  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.

  Throws:
    `IOException`
    `JsonProcessingException`

### readValue

    public abstract <T> T readValue(JsonParser jp,
                                    ResolvedType valueType)
                         throws IOException,
                                JsonProcessingException

  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 `Collection` and `Map`).

  Throws:
    `IOException`
    `JsonProcessingException`

### readTree

    public abstract <T extends TreeNode> T readTree(JsonParser jp)
                                         throws IOException,
                                                JsonProcessingException

  Method to deserialize 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).

  Throws:
    `IOException`
    `JsonProcessingException`

### readValues

    public abstract <T> Iterator<T> readValues(JsonParser jp,
                                               Class<T> valueType)
                                    throws IOException,
                                           JsonProcessingException

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

  Throws:
    `IOException`
    `JsonProcessingException`

### readValues

    public abstract <T> Iterator<T> readValues(JsonParser jp,
                                               TypeReference<?> valueTypeRef)
                                    throws IOException,
                                           JsonProcessingException

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

  Throws:
    `IOException`
    `JsonProcessingException`

### readValues

    public abstract <T> Iterator<T> readValues(JsonParser jp,
                                               ResolvedType valueType)
                                    throws IOException,
                                           JsonProcessingException

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

  Throws:
    `IOException`
    `JsonProcessingException`

### writeValue

    public abstract void writeValue(JsonGenerator jgen,
                                    Object value)
                             throws IOException,
                                    JsonProcessingException

  Method to serialize given Java Object, using generator provided.

  Throws:
    `IOException`
    `JsonProcessingException`

### createObjectNode

    public abstract TreeNode createObjectNode()

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

### createArrayNode

    public abstract TreeNode createArrayNode()

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

### treeAsTokens

    public abstract JsonParser treeAsTokens(TreeNode n)

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

### treeToValue

    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.

  Throws:
    `JsonProcessingException`

### getJsonFactory

    @Deprecated
    public abstract JsonFactory getJsonFactory()

  Deprecated. Since 2.1: Use `getFactory()` instead.

### getFactory

    public JsonFactory getFactory()

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

  Since:
    2.1

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 FasterXML. All Rights Reserved.