org.codehaus.jackson.map
Class ObjectMapper

java.lang.Object
  extended by org.codehaus.jackson.ObjectCodec
      extended by org.codehaus.jackson.map.ObjectMapper

public class ObjectMapper
extends ObjectCodec

This mapper (or, data binder, or codec) provides functionality for conversting between Java objects (instances of JDK provided core classes, beans), and matching JSON constructs. It will use instances of JsonParser and JsonGenerator for implementing actual reading/writing of JSON.

The main conversion API is defined in ObjectCodec, so that implementation details of this class need not be exposed to streaming parser and generator classes.

Note on caching: root-level deserializers are always cached, and accessed using full (generics-aware) type information. This is different from caching of referenced types, which is more limited and is done only for a subset of all deserializer types. The main reason for difference is that at root-level there is no incoming reference (and hence no referencing property, no referral information or annotations to produce differing deserializers), and that the performance impact greatest at root level (since it'll essentially cache the full graph of deserializers involved).


Field Summary
protected  DeserializationConfig _deserializationConfig
          Configuration object that defines basic global settings for the serialization process
protected  DeserializerProvider _deserializerProvider
          Object that manages access to deserializers used for deserializing Json content into Java objects, including possible caching of the deserializers.
protected  JsonFactory _jsonFactory
          Factory used to create JsonParser and JsonGenerator instances as necessary.
protected  JsonNodeFactory _nodeFactory
          Node factory to use for creating
protected  ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _rootDeserializers
          We will use a separate main-level Map for keeping track of root-level deserializers.
protected  SerializationConfig _serializationConfig
          Configuration object that defines basic global settings for the serialization process
protected  SerializerFactory _serializerFactory
          Serializer factory used for constructing serializers.
protected  SerializerProvider _serializerProvider
          Object that manages access to serializers used for serialization, including caching.
protected static AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR
           
protected static ClassIntrospector<? extends BeanDescription> DEFAULT_INTROSPECTOR
           
 
Constructor Summary
ObjectMapper()
          Default constructor, which will construct the default JsonFactory as necessary, use StdSerializerProvider as its SerializerProvider, and BeanSerializerFactory as its SerializerFactory.
ObjectMapper(JsonFactory jf)
           
ObjectMapper(JsonFactory jf, SerializerProvider sp, DeserializerProvider dp)
           
ObjectMapper(JsonFactory jf, SerializerProvider sp, DeserializerProvider dp, SerializationConfig sconfig, DeserializationConfig dconfig)
           
ObjectMapper(SerializerFactory sf)
           
 
Method Summary
protected  void _configAndWriteValue(JsonGenerator jgen, Object value)
          Method called to configure the generator as necessary and then call write functionality
protected  DeserializationContext _createDeserializationContext(JsonParser jp, DeserializationConfig cfg)
           
protected  JsonDeserializer<Object> _findRootDeserializer(JavaType valueType)
          Method called to locate deserializer for the passed root-level value.
protected  JsonToken _initForReading(JsonParser jp)
          Method called to ensure that given parser is ready for reading content for data binding.
protected  Object _readMapAndClose(JsonParser jp, JavaType valueType)
           
protected  Object _readValue(JsonParser jp, JavaType valueType, DeserializationConfig cfg)
          Actual implementation of value reading+binding operation.
 boolean canDeserialize(JavaType type)
          Method that can be called to check whether mapper thinks it could deserialize an Object of given type.
 boolean canSerialize(Class<?> type)
          Method that can be called to check whether mapper thinks it could serialize an instance of given Class.
 ObjectMapper configure(DeserializationConfig.Feature f, boolean state)
          Method for changing state of an on/off deserialization feature for this object mapper.
 ObjectMapper configure(JsonGenerator.Feature f, boolean state)
          Method for changing state of an on/off JsonGenerator feature for JsonFactory instance this object mapper uses.
 ObjectMapper configure(JsonParser.Feature f, boolean state)
          Method for changing state of an on/off JsonParser feature for JsonFactory instance this object mapper uses.
 ObjectMapper configure(SerializationConfig.Feature f, boolean state)
          Method for changing state of an on/off serialization feature for this object mapper.
 DeserializationConfig copyDeserializationConfig()
          Method that creates a copy of the shared default DeserializationConfig object that defines configuration settings for deserialization.
 SerializationConfig copySerializationConfig()
          Method that creates a copy of the shared default SerializationConfig object that defines configuration settings for serialization.
 ArrayNode createArrayNode()
           Note: return type is co-variant, as basic ObjectCodec abstraction can not refer to concrete node types (as it's part of core package, whereas impls are part of mapper package)
 ObjectNode createObjectNode()
           Note: return type is co-variant, as basic ObjectCodec abstraction can not refer to concrete node types (as it's part of core package, whereas impls are part of mapper package)
 JsonSchema generateJsonSchema(Class<?> t)
          Generate the Json-schema} for the specified class.
 JsonSchema generateJsonSchema(Class<?> t, SerializationConfig cfg)
           
 DeserializationConfig getDeserializationConfig()
          Method that returns the shared default DeserializationConfig object that defines configuration settings for deserialization.
 JsonFactory getJsonFactory()
          Method that can be used to get hold of Json factory that this mapper uses if it needs to construct Json parsers and/or generators.
 JsonNodeFactory getNodeFactory()
          Method that can be used to get hold of JsonNodeFactory that this mapper will use when directly constructing root JsonNode instances for Trees.
 SerializationConfig getSerializationConfig()
          Method that returns the shared default SerializationConfig object that defines configuration settings for serialization.
 JsonNode readTree(JsonParser jp)
          Method to deserialize Json content as tree expressed using set of JsonNode instances.
 JsonNode readTree(JsonParser jp, DeserializationConfig cfg)
          Method to deserialize Json content as tree expressed using set of JsonNode instances.
<T> T
readValue(byte[] src, int offset, int len, Class<T> valueType)
           
<T> T
readValue(byte[] src, int offset, int len, JavaType valueType)
           
<T> T
readValue(byte[] src, int offset, int len, TypeReference valueTypeRef)
           
<T> T
readValue(File src, Class<T> valueType)
           
<T> T
readValue(File src, JavaType valueType)
           
<T> T
readValue(File src, TypeReference valueTypeRef)
           
<T> T
readValue(InputStream src, Class<T> valueType)
           
<T> T
readValue(InputStream src, JavaType valueType)
           
<T> T
readValue(InputStream src, TypeReference valueTypeRef)
           
<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).
<T> T
readValue(JsonParser jp, Class<T> valueType, DeserializationConfig cfg)
          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).
<T> T
readValue(JsonParser jp, JavaType valueType)
          Method to deserialize Json content into a Java type, reference to which is passed as argument.
<T> T
readValue(JsonParser jp, JavaType valueType, DeserializationConfig cfg)
          Method to deserialize Json content into a Java type, reference to which is passed as argument.
<T> T
readValue(JsonParser jp, TypeReference<?> valueTypeRef)
          Method to deserialize Json content into a Java type, reference to which is passed as argument.
<T> T
readValue(JsonParser jp, TypeReference<?> valueTypeRef, DeserializationConfig cfg)
          Method to deserialize Json content into a Java type, reference to which is passed as argument.
<T> T
readValue(Reader src, Class<T> valueType)
           
<T> T
readValue(Reader src, JavaType valueType)
           
<T> T
readValue(Reader src, TypeReference valueTypeRef)
           
<T> T
readValue(String content, Class<T> valueType)
           
<T> T
readValue(String content, JavaType valueType)
           
<T> T
readValue(String content, TypeReference valueTypeRef)
           
<T> T
readValue(URL src, Class<T> valueType)
           
<T> T
readValue(URL src, JavaType valueType)
           
<T> T
readValue(URL src, TypeReference valueTypeRef)
           
 ObjectMapper setDeserializationConfig(DeserializationConfig cfg)
          Method for replacing the shared default deserialization configuration object.
 ObjectMapper setDeserializerProvider(DeserializerProvider p)
          Method for setting specific DeserializerProvider to use for handling caching of JsonDeserializer instances.
 ObjectMapper setNodeFactory(JsonNodeFactory f)
          Method for specifying JsonNodeFactory to use for constructing root level tree nodes (via method createObjectNode()
 ObjectMapper setSerializationConfig(SerializationConfig cfg)
          Method for replacing the shared default serialization configuration object.
 ObjectMapper setSerializerFactory(SerializerFactory f)
          Method for setting specific SerializerFactory to use for constructing (bean) serializers.
 ObjectMapper setSerializerProvider(SerializerProvider p)
          Method for setting specific SerializerProvider to use for handling caching of JsonSerializer instances.
 void writeTree(JsonGenerator jgen, JsonNode rootNode)
          Method to serialize given Json Tree, using generator provided.
 void writeTree(JsonGenerator jgen, JsonNode rootNode, SerializationConfig cfg)
          Method to serialize given Json Tree, using generator provided.
 void writeValue(File resultFile, Object value)
          Method that can be used to serialize any Java value as Json output, written to File provided.
 void writeValue(JsonGenerator jgen, Object value)
          Method that can be used to serialize any Java value as Json output, using provided JsonGenerator.
 void writeValue(JsonGenerator jgen, Object value, SerializationConfig config)
          Method that can be used to serialize any Java value as Json output, using provided JsonGenerator, configured as per passed configuration object.
 void writeValue(OutputStream out, Object value)
          Method that can be used to serialize any Java value as Json output, using output stream provided (using encoding {JsonEncoding.UTF8).
 void writeValue(Writer w, Object value)
          Method that can be used to serialize any Java value as Json output, using Writer provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INTROSPECTOR

protected static final ClassIntrospector<? extends BeanDescription> DEFAULT_INTROSPECTOR

DEFAULT_ANNOTATION_INTROSPECTOR

protected static final AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR

_jsonFactory

protected final JsonFactory _jsonFactory
Factory used to create JsonParser and JsonGenerator instances as necessary.


_serializationConfig

protected SerializationConfig _serializationConfig
Configuration object that defines basic global settings for the serialization process


_serializerProvider

protected SerializerProvider _serializerProvider
Object that manages access to serializers used for serialization, including caching. It is configured with _serializerFactory to allow for constructing custom serializers.


_serializerFactory

protected SerializerFactory _serializerFactory
Serializer factory used for constructing serializers.


_deserializationConfig

protected DeserializationConfig _deserializationConfig
Configuration object that defines basic global settings for the serialization process


_deserializerProvider

protected DeserializerProvider _deserializerProvider
Object that manages access to deserializers used for deserializing Json content into Java objects, including possible caching of the deserializers. It contains a reference to DeserializerFactory to use for constructing acutal deserializers.


_nodeFactory

protected JsonNodeFactory _nodeFactory
Node factory to use for creating

Since:
1.2

_rootDeserializers

protected final ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _rootDeserializers
We will use a separate main-level Map for keeping track of root-level deserializers. This is where most succesful cache lookups get resolved. Map will contain resolvers for all kinds of types, including container types: this is different from the component cache which will only cache bean deserializers.

Given that we don't expect much concurrency for additions (should very quickly converge to zero after startup), let's explicitly define a low concurrency setting.

Constructor Detail

ObjectMapper

public ObjectMapper()
Default constructor, which will construct the default JsonFactory as necessary, use StdSerializerProvider as its SerializerProvider, and BeanSerializerFactory as its SerializerFactory. This means that it can serialize all standard JDK types, as well as regular Java Beans (based on method names and Jackson-specific annotations), but does not support JAXB annotations.


ObjectMapper

public ObjectMapper(JsonFactory jf)

ObjectMapper

public ObjectMapper(SerializerFactory sf)

ObjectMapper

public ObjectMapper(JsonFactory jf,
                    SerializerProvider sp,
                    DeserializerProvider dp)

ObjectMapper

public ObjectMapper(JsonFactory jf,
                    SerializerProvider sp,
                    DeserializerProvider dp,
                    SerializationConfig sconfig,
                    DeserializationConfig dconfig)
Parameters:
jf - JsonFactory to use: if null, a new MappingJsonFactory will be constructed
sp - SerializerProvider to use: if null, a StdSerializerProvider will be constructed
dp - DeserializerProvider to use: if null, a StdDeserializerProvider will be constructed
sconfig - Serialization configuration to use; if null, basic SerializationConfig will be constructed
dconfig - Deserialization configuration to use; if null, basic DeserializationConfig will be constructed
Method Detail

setSerializerFactory

public ObjectMapper setSerializerFactory(SerializerFactory f)
Method for setting specific SerializerFactory to use for constructing (bean) serializers.


setSerializerProvider

public ObjectMapper setSerializerProvider(SerializerProvider p)
Method for setting specific SerializerProvider to use for handling caching of JsonSerializer instances.


setDeserializerProvider

public ObjectMapper setDeserializerProvider(DeserializerProvider p)
Method for setting specific DeserializerProvider to use for handling caching of JsonDeserializer instances.


setNodeFactory

public ObjectMapper setNodeFactory(JsonNodeFactory f)
Method for specifying JsonNodeFactory to use for constructing root level tree nodes (via method createObjectNode()

Since:
1.2

getSerializationConfig

public SerializationConfig getSerializationConfig()
Method that returns the shared default SerializationConfig object that defines configuration settings for serialization. Returned object is "live" meaning that changes will be used for future serialization operations for this mapper when using mapper's default configuration


copySerializationConfig

public SerializationConfig copySerializationConfig()
Method that creates a copy of the shared default SerializationConfig object that defines configuration settings for serialization. Since it is a copy, any changes made to the configuration object will NOT directly affect serialization done using basic serialization methods that use the shared object (that is, ones that do not take separate SerializationConfig argument.

The use case is that of changing object settings of the configuration (like date format being used, see SerializationConfig.setDateFormat(java.text.DateFormat)).


setSerializationConfig

public ObjectMapper setSerializationConfig(SerializationConfig cfg)
Method for replacing the shared default serialization configuration object.


configure

public ObjectMapper configure(SerializationConfig.Feature f,
                              boolean state)
Method for changing state of an on/off serialization feature for this object mapper.

This is method is basically a shortcut method for calling SerializationConfig.set(org.codehaus.jackson.map.SerializationConfig.Feature, boolean) on the shared SerializationConfig object with given arguments.


getDeserializationConfig

public DeserializationConfig getDeserializationConfig()
Method that returns the shared default DeserializationConfig object that defines configuration settings for deserialization. Returned object is "live" meaning that changes will be used for future deserialization operations for this mapper when using mapper's default configuration


copyDeserializationConfig

public DeserializationConfig copyDeserializationConfig()
Method that creates a copy of the shared default DeserializationConfig object that defines configuration settings for deserialization. Since it is a copy, any changes made to the configuration object will NOT directly affect deserialization done using basic deserialization methods that use the shared object (that is, ones that do not take separate DeserializationConfig argument.

The use case is that of changing object settings of the configuration (like deserialization problem handler, see DeserializationConfig.addHandler(org.codehaus.jackson.map.DeserializationProblemHandler))


setDeserializationConfig

public ObjectMapper setDeserializationConfig(DeserializationConfig cfg)
Method for replacing the shared default deserialization configuration object.


configure

public ObjectMapper configure(DeserializationConfig.Feature f,
                              boolean state)
Method for changing state of an on/off deserialization feature for this object mapper.

This is method is basically a shortcut method for calling DeserializationConfig.set(org.codehaus.jackson.map.DeserializationConfig.Feature, boolean) on the shared DeserializationConfig object with given arguments.


getJsonFactory

public JsonFactory getJsonFactory()
Method that can be used to get hold of Json factory that this mapper uses if it needs to construct Json parsers and/or generators.

Returns:
Json factory that this mapper uses when it needs to construct Json parser and generators

configure

public ObjectMapper configure(JsonParser.Feature f,
                              boolean state)
Method for changing state of an on/off JsonParser feature for JsonFactory instance this object mapper uses.

This is method is basically a shortcut method for calling JsonFactory.setParserFeature(org.codehaus.jackson.JsonParser.Feature, boolean) on the shared JsonFactory this mapper uses (which is accessible using getJsonFactory()).

Since:
1.2

configure

public ObjectMapper configure(JsonGenerator.Feature f,
                              boolean state)
Method for changing state of an on/off JsonGenerator feature for JsonFactory instance this object mapper uses.

This is method is basically a shortcut method for calling JsonFactory.setGeneratorFeature(org.codehaus.jackson.JsonGenerator.Feature, boolean) on the shared JsonFactory this mapper uses (which is accessible using getJsonFactory()).

Since:
1.2

getNodeFactory

public JsonNodeFactory getNodeFactory()
Method that can be used to get hold of JsonNodeFactory that this mapper will use when directly constructing root JsonNode instances for Trees.

Since:
1.2

readValue

public <T> T readValue(JsonParser jp,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
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.

Specified by:
readValue in class ObjectCodec
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(JsonParser jp,
                       Class<T> valueType,
                       DeserializationConfig cfg)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
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.

Parameters:
cfg - Specific deserialization configuration to use for this operation. Note that not all config settings can be changed on per-operation basis: some changeds only take effect before calling the operation for the first time (for the mapper instance)
Throws:
IOException
JsonParseException
JsonMappingException
Since:
1.1

readValue

public <T> T readValue(JsonParser jp,
                       TypeReference<?> valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
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" (see ) and specifically needs to be used if the root type is a parameterized (generic) container type.

Specified by:
readValue in class ObjectCodec
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(JsonParser jp,
                       TypeReference<?> valueTypeRef,
                       DeserializationConfig cfg)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
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" (see ) and specifically needs to be used if the root type is a parameterized (generic) container type.

Parameters:
cfg - Specific deserialization configuration to use for this operation. Note that not all config settings can be changed on per-operation basis: some changeds only take effect before calling the operation for the first time (for the mapper instance)
Throws:
IOException
JsonParseException
JsonMappingException
Since:
1.1

readValue

public <T> T readValue(JsonParser jp,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Method to deserialize Json content into a Java type, reference to which is passed as argument. Type is passed using Jackson specific type; instance of which can be constructed using TypeFactory.

Specified by:
readValue in class ObjectCodec
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(JsonParser jp,
                       JavaType valueType,
                       DeserializationConfig cfg)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Method to deserialize Json content into a Java type, reference to which is passed as argument. Type is passed using Jackson specific type; instance of which can be constructed using TypeFactory.

Parameters:
cfg - Specific deserialization configuration to use for this operation. Note that not all config settings can be changed on per-operation basis: some changeds only take effect before calling the operation for the first time (for the mapper instance)
Throws:
IOException
JsonParseException
JsonMappingException
Since:
1.1

readTree

public JsonNode readTree(JsonParser jp)
                  throws IOException,
                         JsonProcessingException
Method to deserialize Json content as tree expressed using set of JsonNode 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).

Specified by:
readTree in class ObjectCodec
Throws:
IOException
JsonProcessingException

readTree

public JsonNode readTree(JsonParser jp,
                         DeserializationConfig cfg)
                  throws IOException,
                         JsonProcessingException
Method to deserialize Json content as tree expressed using set of JsonNode 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).

Parameters:
cfg - Specific deserialization configuration to use for this operation. Note that not all config settings can be changed on per-operation basis: some changeds only take effect before calling the operation for the first time (for the mapper instance)
Throws:
IOException
JsonProcessingException
Since:
1.1

writeValue

public void writeValue(JsonGenerator jgen,
                       Object value)
                throws IOException,
                       JsonGenerationException,
                       JsonMappingException
Method that can be used to serialize any Java value as Json output, using provided JsonGenerator.

Specified by:
writeValue in class ObjectCodec
Throws:
IOException
JsonGenerationException
JsonMappingException

writeValue

public void writeValue(JsonGenerator jgen,
                       Object value,
                       SerializationConfig config)
                throws IOException,
                       JsonGenerationException,
                       JsonMappingException
Method that can be used to serialize any Java value as Json output, using provided JsonGenerator, configured as per passed configuration object.

Throws:
IOException
JsonGenerationException
JsonMappingException
Since:
1.1

writeTree

public void writeTree(JsonGenerator jgen,
                      JsonNode rootNode)
               throws IOException,
                      JsonProcessingException
Method to serialize given Json Tree, using generator provided.

Specified by:
writeTree in class ObjectCodec
Throws:
IOException
JsonProcessingException

writeTree

public void writeTree(JsonGenerator jgen,
                      JsonNode rootNode,
                      SerializationConfig cfg)
               throws IOException,
                      JsonProcessingException
Method to serialize given Json Tree, using generator provided.

Throws:
IOException
JsonProcessingException
Since:
1.1

createObjectNode

public ObjectNode createObjectNode()

Note: return type is co-variant, as basic ObjectCodec abstraction can not refer to concrete node types (as it's part of core package, whereas impls are part of mapper package)

Specified by:
createObjectNode in class ObjectCodec
Since:
1.2

createArrayNode

public ArrayNode createArrayNode()

Note: return type is co-variant, as basic ObjectCodec abstraction can not refer to concrete node types (as it's part of core package, whereas impls are part of mapper package)

Specified by:
createArrayNode in class ObjectCodec
Since:
1.2

canSerialize

public boolean canSerialize(Class<?> type)
Method that can be called to check whether mapper thinks it could serialize an instance of given Class. Check is done by checking whether a serializer can be found for the type.

Returns:
True if mapper can find a serializer for instances of given class (potentially serializable), false otherwise (not serializable)

canDeserialize

public boolean canDeserialize(JavaType type)
Method that can be called to check whether mapper thinks it could deserialize an Object of given type. Check is done by checking whether a deserializer can be found for the type.

Returns:
True if mapper can find a serializer for instances of given class (potentially serializable), false otherwise (not serializable)

readValue

public <T> T readValue(File src,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(File src,
                       TypeReference valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(File src,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(URL src,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(URL src,
                       TypeReference valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(URL src,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(String content,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(String content,
                       TypeReference valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(String content,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(Reader src,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(Reader src,
                       TypeReference valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(Reader src,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(InputStream src,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(InputStream src,
                       TypeReference valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(InputStream src,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(byte[] src,
                       int offset,
                       int len,
                       Class<T> valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(byte[] src,
                       int offset,
                       int len,
                       TypeReference valueTypeRef)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

readValue

public <T> T readValue(byte[] src,
                       int offset,
                       int len,
                       JavaType valueType)
            throws IOException,
                   JsonParseException,
                   JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

writeValue

public void writeValue(File resultFile,
                       Object value)
                throws IOException,
                       JsonGenerationException,
                       JsonMappingException
Method that can be used to serialize any Java value as Json output, written to File provided.

Throws:
IOException
JsonGenerationException
JsonMappingException

writeValue

public void writeValue(OutputStream out,
                       Object value)
                throws IOException,
                       JsonGenerationException,
                       JsonMappingException
Method that can be used to serialize any Java value as Json output, using output stream provided (using encoding {JsonEncoding.UTF8).

Note: method does not close the underlying stream explicitly here; however, JsonFactory this mapper uses may choose to close the stream depending on its settings (by default, it will try to close it when JsonGenerator we construct is closed).

Throws:
IOException
JsonGenerationException
JsonMappingException

writeValue

public void writeValue(Writer w,
                       Object value)
                throws IOException,
                       JsonGenerationException,
                       JsonMappingException
Method that can be used to serialize any Java value as Json output, using Writer provided.

Note: method does not close the underlying stream explicitly here; however, JsonFactory this mapper uses may choose to close the stream depending on its settings (by default, it will try to close it when JsonGenerator we construct is closed).

Throws:
IOException
JsonGenerationException
JsonMappingException

generateJsonSchema

public JsonSchema generateJsonSchema(Class<?> t)
                              throws JsonMappingException
Generate the Json-schema} for the specified class.

Parameters:
t - The class.
Returns:
The json-schema.
Throws:
JsonMappingException

generateJsonSchema

public JsonSchema generateJsonSchema(Class<?> t,
                                     SerializationConfig cfg)
                              throws JsonMappingException
Throws:
JsonMappingException

_configAndWriteValue

protected final void _configAndWriteValue(JsonGenerator jgen,
                                          Object value)
                                   throws IOException,
                                          JsonGenerationException,
                                          JsonMappingException
Method called to configure the generator as necessary and then call write functionality

Throws:
IOException
JsonGenerationException
JsonMappingException

_readValue

protected Object _readValue(JsonParser jp,
                            JavaType valueType,
                            DeserializationConfig cfg)
                     throws IOException,
                            JsonParseException,
                            JsonMappingException
Actual implementation of value reading+binding operation.

Throws:
IOException
JsonParseException
JsonMappingException

_readMapAndClose

protected Object _readMapAndClose(JsonParser jp,
                                  JavaType valueType)
                           throws IOException,
                                  JsonParseException,
                                  JsonMappingException
Throws:
IOException
JsonParseException
JsonMappingException

_initForReading

protected JsonToken _initForReading(JsonParser jp)
                             throws IOException,
                                    JsonParseException,
                                    JsonMappingException
Method called to ensure that given parser is ready for reading content for data binding.

Returns:
First token to be used for data binding after this call: can never be null as exception will be thrown if parser can not provide more tokens.
Throws:
IOException - if the underlying input source has problems during parsing
JsonParseException - if parser has problems parsing content
JsonMappingException - if the parser does not have any more content to map (note: Json "null" value is considered content; enf-of-stream not)

_findRootDeserializer

protected JsonDeserializer<Object> _findRootDeserializer(JavaType valueType)
                                                  throws JsonMappingException
Method called to locate deserializer for the passed root-level value.

Throws:
JsonMappingException

_createDeserializationContext

protected DeserializationContext _createDeserializationContext(JsonParser jp,
                                                               DeserializationConfig cfg)