|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasterxml.jackson.core.ObjectCodec com.fasterxml.jackson.databind.ObjectMapper
public class ObjectMapper
This mapper (or, data binder, or codec) provides functionality for
converting 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).
Nested Class Summary | |
---|---|
static class |
ObjectMapper.DefaultTypeResolverBuilder
Customized TypeResolverBuilder that provides type resolver builders
used with so-called "default typing"
(see enableDefaultTyping() for details). |
static class |
ObjectMapper.DefaultTyping
Enumeration used with enableDefaultTyping()
to specify what kind of types (classes) default typing should
be used for. |
Field Summary | |
---|---|
protected DeserializationConfig |
_deserializationConfig
Configuration object that defines basic global settings for the serialization process |
protected DefaultDeserializationContext |
_deserializationContext
Blueprint context object; stored here to allow custom sub-classes. |
protected InjectableValues |
_injectableValues
Provider for values to inject in deserialized POJOs. |
protected com.fasterxml.jackson.core.JsonFactory |
_jsonFactory
Factory used to create JsonParser and JsonGenerator
instances as necessary. |
protected HashMap<ClassKey,Class<?>> |
_mixInAnnotations
Mapping that defines how to apply mix-in annotations: key is the type to received additional annotations, and value is the type that has annotations to "mix in". |
protected ConcurrentHashMap<JavaType,JsonDeserializer<Object>> |
_rootDeserializers
We will use a separate main-level Map for keeping track of root-level deserializers. |
protected RootNameLookup |
_rootNames
Cache for root names used when root-wrapping is enabled. |
protected SerializationConfig |
_serializationConfig
Configuration object that defines basic global settings for the serialization process |
protected SerializerFactory |
_serializerFactory
Serializer factory used for constructing serializers. |
protected DefaultSerializerProvider |
_serializerProvider
Object that manages access to serializers used for serialization, including caching. |
protected SubtypeResolver |
_subtypeResolver
Thing used for registering sub-types, resolving them to super/sub-types as needed. |
protected TypeFactory |
_typeFactory
Specific factory used for creating JavaType instances;
needed to allow modules to add more custom type handling
(mostly to support types of non-Java JVM languages) |
protected static AnnotationIntrospector |
DEFAULT_ANNOTATION_INTROSPECTOR
|
protected static BaseSettings |
DEFAULT_BASE
Base settings contain defaults used for all ObjectMapper
instances. |
protected static ClassIntrospector |
DEFAULT_INTROSPECTOR
|
protected static VisibilityChecker<?> |
STD_VISIBILITY_CHECKER
|
Constructor Summary | |
---|---|
ObjectMapper()
Default constructor, which will construct the default JsonFactory as necessary, use
SerializerProvider as its
SerializerProvider , and
BeanSerializerFactory as its
SerializerFactory . |
|
ObjectMapper(com.fasterxml.jackson.core.JsonFactory jf)
Constructs instance that uses specified JsonFactory
for constructing necessary JsonParser s and/or
JsonGenerator s. |
|
ObjectMapper(com.fasterxml.jackson.core.JsonFactory jf,
DefaultSerializerProvider sp,
DefaultDeserializationContext dc)
Constructs instance that uses specified JsonFactory
for constructing necessary JsonParser s and/or
JsonGenerator s, and uses given providers for accessing
serializers and deserializers. |
Method Summary | ||
---|---|---|
protected void |
_configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator jgen,
Object value)
Method called to configure the generator as necessary and then call write functionality |
|
protected void |
_configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator jgen,
Object value,
Class<?> viewClass)
|
|
protected Object |
_convert(Object fromValue,
JavaType toValueType)
Actual conversion implementation: instead of using existing read and write methods, much of code is inlined. |
|
protected com.fasterxml.jackson.core.PrettyPrinter |
_defaultPrettyPrinter()
Helper method that should return default pretty-printer to use for generators constructed by this mapper, when instructed to use default pretty printer. |
|
protected JsonDeserializer<Object> |
_findRootDeserializer(DeserializationContext ctxt,
JavaType valueType)
Method called to locate deserializer for the passed root-level value. |
|
protected com.fasterxml.jackson.core.JsonToken |
_initForReading(com.fasterxml.jackson.core.JsonParser jp)
Method called to ensure that given parser is ready for reading content for data binding. |
|
protected Object |
_readMapAndClose(com.fasterxml.jackson.core.JsonParser jp,
JavaType valueType)
|
|
protected Object |
_readValue(DeserializationConfig cfg,
com.fasterxml.jackson.core.JsonParser jp,
JavaType valueType)
Actual implementation of value reading+binding operation. |
|
protected DefaultSerializerProvider |
_serializerProvider(SerializationConfig config)
Overridable helper method used for constructing SerializerProvider to use for serialization. |
|
protected Object |
_unwrapAndDeserialize(com.fasterxml.jackson.core.JsonParser jp,
DeserializationContext ctxt,
DeserializationConfig config,
JavaType rootType,
JsonDeserializer<Object> deser)
|
|
ObjectMapper |
addHandler(DeserializationProblemHandler h)
Method for adding specified DeserializationProblemHandler
to be used for handling specific problems during deserialization. |
|
void |
addMixInAnnotations(Class<?> target,
Class<?> mixinSource)
Method to use for adding mix-in annotations to use for augmenting specified class or interface. |
|
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 |
clearProblemHandlers()
Method for removing all registered DeserializationProblemHandler s
instances from this mapper. |
|
ObjectMapper |
configure(DeserializationFeature f,
boolean state)
Method for changing state of an on/off deserialization feature for this object mapper. |
|
ObjectMapper |
configure(com.fasterxml.jackson.core.JsonGenerator.Feature f,
boolean state)
Method for changing state of an on/off JsonGenerator feature for
JsonFactory instance this object mapper uses. |
|
ObjectMapper |
configure(com.fasterxml.jackson.core.JsonParser.Feature f,
boolean state)
Method for changing state of an on/off JsonParser feature for
JsonFactory instance this object mapper uses. |
|
ObjectMapper |
configure(MapperFeature f,
boolean state)
Method for changing state of an on/off mapper feature for this mapper instance. |
|
ObjectMapper |
configure(SerializationFeature f,
boolean state)
Method for changing state of an on/off serialization feature for this object mapper. |
|
JavaType |
constructType(Type t)
Convenience method for constructing JavaType out of given
type (typically java.lang.Class ), but without explicit
context. |
|
|
convertValue(Object fromValue,
Class<T> toValueType)
Convenience method for doing two-step conversion from given value, into instance of given value type. |
|
|
convertValue(Object fromValue,
JavaType toValueType)
|
|
|
convertValue(Object fromValue,
com.fasterxml.jackson.core.type.TypeReference toValueTypeRef)
|
|
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) |
|
protected DefaultDeserializationContext |
createDeserializationContext(com.fasterxml.jackson.core.JsonParser jp,
DeserializationConfig cfg)
Internal helper method called to create an instance of DeserializationContext
for deserializing a single root value. |
|
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) |
|
ObjectMapper |
disable(DeserializationFeature feature)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
disable(DeserializationFeature first,
DeserializationFeature... f)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
disable(MapperFeature... f)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
disable(SerializationFeature f)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
disable(SerializationFeature first,
SerializationFeature... f)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
disableDefaultTyping()
Method for disabling automatic inclusion of type information; if so, only explicitly annotated types (ones with JsonTypeInfo ) will have
additional embedded type information. |
|
ObjectMapper |
enable(DeserializationFeature feature)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
enable(DeserializationFeature first,
DeserializationFeature... f)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
enable(MapperFeature... f)
Method for enabling specified MapperConfig features. |
|
ObjectMapper |
enable(SerializationFeature f)
Method for enabling specified DeserializationConfig feature. |
|
ObjectMapper |
enable(SerializationFeature first,
SerializationFeature... f)
Method for enabling specified DeserializationConfig features. |
|
ObjectMapper |
enableDefaultTyping()
Convenience method that is equivalent to calling |
|
ObjectMapper |
enableDefaultTyping(ObjectMapper.DefaultTyping dti)
Convenience method that is equivalent to calling |
|
ObjectMapper |
enableDefaultTyping(ObjectMapper.DefaultTyping applicability,
com.fasterxml.jackson.annotation.JsonTypeInfo.As includeAs)
Method for enabling automatic inclusion of type information, needed for proper deserialization of polymorphic types (unless types have been annotated with JsonTypeInfo ). |
|
ObjectMapper |
enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping applicability,
String propertyName)
Method for enabling automatic inclusion of type information -- needed for proper deserialization of polymorphic types (unless types have been annotated with JsonTypeInfo ) --
using "As.PROPERTY" inclusion mechanism and specified property name
to use for inclusion (default being "@class" since default type information
always uses class name as type identifier) |
|
Class<?> |
findMixInClassFor(Class<?> cls)
|
|
JsonSchema |
generateJsonSchema(Class<?> t)
Generate Json-schema instance for specified class. |
|
DeserializationConfig |
getDeserializationConfig()
Method that returns the shared default DeserializationConfig object
that defines configuration settings for deserialization. |
|
com.fasterxml.jackson.core.JsonFactory |
getJsonFactory()
Method that can be used to get hold of JsonFactory that this
mapper uses if it needs to construct JsonParser s
and/or JsonGenerator s. |
|
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. |
|
SerializerProvider |
getSerializerProvider()
|
|
SubtypeResolver |
getSubtypeResolver()
Method for accessing subtype resolver in use. |
|
TypeFactory |
getTypeFactory()
Accessor for getting currently configured TypeFactory instance. |
|
VisibilityChecker<?> |
getVisibilityChecker()
Method for accessing currently configured visibility checker; object used for determining whether given property element (method, field, constructor) can be auto-detected or not. |
|
boolean |
isEnabled(DeserializationFeature f)
Method for checking whether given deserialization-specific feature is enabled. |
|
boolean |
isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f)
Convenience method, equivalent to: |
|
boolean |
isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f)
Convenience method, equivalent to: |
|
boolean |
isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f)
Convenience method, equivalent to: |
|
boolean |
isEnabled(MapperFeature f)
Method for checking whether given Mapper feature is enabled. |
|
boolean |
isEnabled(SerializationFeature f)
Method for checking whether given serialization-specific feature is enabled. |
|
int |
mixInCount()
|
|
ObjectReader |
reader()
Factory method for constructing ObjectReader with
default settings. |
|
ObjectReader |
reader(Class<?> type)
Factory method for constructing ObjectReader that will
read or update instances of specified type |
|
ObjectReader |
reader(DeserializationFeature feature)
Factory method for constructing ObjectReader with
specified feature enabled (compared to settings that this
mapper instance has). |
|
ObjectReader |
reader(DeserializationFeature first,
DeserializationFeature... other)
Factory method for constructing ObjectReader with
specified features enabled (compared to settings that this
mapper instance has). |
|
ObjectReader |
reader(com.fasterxml.jackson.core.FormatSchema schema)
Factory method for constructing ObjectReader that will
pass specific schema object to JsonParser used for
reading content. |
|
ObjectReader |
reader(InjectableValues injectableValues)
Factory method for constructing ObjectReader that will
use specified injectable values. |
|
ObjectReader |
reader(JavaType type)
Factory method for constructing ObjectReader that will
read or update instances of specified type |
|
ObjectReader |
reader(JsonNodeFactory f)
Factory method for constructing ObjectReader that will
use specified JsonNodeFactory for constructing JSON trees. |
|
ObjectReader |
reader(com.fasterxml.jackson.core.type.TypeReference<?> type)
Factory method for constructing ObjectReader that will
read or update instances of specified type |
|
ObjectReader |
readerForUpdating(Object valueToUpdate)
Factory method for constructing ObjectReader that will
update given Object (usually Bean, but can be a Collection or Map
as well, but NOT an array) with JSON data. |
|
ObjectReader |
readerWithView(Class<?> view)
Factory method for constructing ObjectReader that will
deserialize objects using specified JSON View (filter). |
|
JsonNode |
readTree(byte[] content)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
JsonNode |
readTree(File file)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
JsonNode |
readTree(InputStream in)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
|
readTree(com.fasterxml.jackson.core.JsonParser jp)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
JsonNode |
readTree(Reader r)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
JsonNode |
readTree(String content)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
JsonNode |
readTree(URL source)
Method to deserialize JSON content as tree expressed using set of JsonNode instances. |
|
|
readValue(byte[] src,
Class<T> valueType)
|
|
|
readValue(byte[] src,
int offset,
int len,
Class<T> valueType)
|
|
|
readValue(byte[] src,
int offset,
int len,
JavaType valueType)
|
|
|
readValue(byte[] src,
int offset,
int len,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValue(byte[] src,
JavaType valueType)
|
|
|
readValue(byte[] src,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValue(File src,
Class<T> valueType)
|
|
|
readValue(File src,
JavaType valueType)
|
|
|
readValue(File src,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValue(InputStream src,
Class<T> valueType)
|
|
|
readValue(InputStream src,
JavaType valueType)
|
|
|
readValue(InputStream src,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValue(com.fasterxml.jackson.core.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 ). |
|
|
readValue(com.fasterxml.jackson.core.JsonParser jp,
JavaType valueType)
Type-safe overloaded method, basically alias for readValues(JsonParser, ResolvedType) . |
|
|
readValue(com.fasterxml.jackson.core.JsonParser jp,
com.fasterxml.jackson.core.type.ResolvedType valueType)
Method to deserialize JSON content into a Java type, reference to which is passed as argument. |
|
|
readValue(com.fasterxml.jackson.core.JsonParser jp,
com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef)
Method to deserialize JSON content into a Java type, reference to which is passed as argument. |
|
|
readValue(Reader src,
Class<T> valueType)
|
|
|
readValue(Reader src,
JavaType valueType)
|
|
|
readValue(Reader src,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValue(String content,
Class<T> valueType)
|
|
|
readValue(String content,
JavaType valueType)
|
|
|
readValue(String content,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValue(URL src,
Class<T> valueType)
|
|
|
readValue(URL src,
JavaType valueType)
|
|
|
readValue(URL src,
com.fasterxml.jackson.core.type.TypeReference valueTypeRef)
|
|
|
readValues(com.fasterxml.jackson.core.JsonParser jp,
Class<T> valueType)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(com.fasterxml.jackson.core.JsonParser jp,
JavaType valueType)
Type-safe overloaded method, basically alias for readValues(JsonParser, ResolvedType) . |
|
|
readValues(com.fasterxml.jackson.core.JsonParser jp,
com.fasterxml.jackson.core.type.ResolvedType valueType)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(com.fasterxml.jackson.core.JsonParser jp,
com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef)
Method for reading sequence of Objects from parser stream. |
|
ObjectMapper |
registerModule(Module module)
Method for registering a module that can extend functionality provided by this mapper; for example, by adding providers for custom serializers and deserializers. |
|
void |
registerSubtypes(Class<?>... classes)
Method for registering specified class as a subtype, so that typename-based resolution can link supertypes to subtypes (as an alternative to using annotations). |
|
void |
registerSubtypes(NamedType... types)
Method for registering specified class as a subtype, so that typename-based resolution can link supertypes to subtypes (as an alternative to using annotations). |
|
ObjectMapper |
setAnnotationIntrospector(AnnotationIntrospector ai)
Method for changing AnnotationIntrospector used by this
mapper instance for both serialization and deserialization |
|
ObjectMapper |
setDateFormat(DateFormat dateFormat)
Method for configuring the default DateFormat to use when serializing time
values as Strings, and deserializing from JSON Strings. |
|
ObjectMapper |
setDefaultTyping(TypeResolverBuilder<?> typer)
Method for enabling automatic inclusion of type information, using specified handler object for determining which types this affects, as well as details of how information is embedded. |
|
void |
setFilters(FilterProvider filterProvider)
Convenience method that is equivalent to: |
|
Object |
setHandlerInstantiator(HandlerInstantiator hi)
Method for configuring HandlerInstantiator to use for creating
instances of handlers (such as serializers, deserializers, type and type
id resolvers), given a class. |
|
ObjectMapper |
setInjectableValues(InjectableValues injectableValues)
Method for configuring InjectableValues which used to find
values to inject. |
|
ObjectMapper |
setLocale(Locale l)
Method for overriding default locale to use for formatting. |
|
void |
setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
Method to use for defining mix-in annotations to use for augmenting annotations that processable (serializable / deserializable) classes have. |
|
ObjectMapper |
setNodeFactory(JsonNodeFactory f)
Method for specifying JsonNodeFactory to use for
constructing root level tree nodes (via method
createObjectNode() |
|
ObjectMapper |
setPropertyNamingStrategy(PropertyNamingStrategy s)
Method for setting custom property naming strategy to use. |
|
ObjectMapper |
setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include incl)
Method for setting defalt POJO property inclusion strategy for serialization. |
|
ObjectMapper |
setSerializerFactory(SerializerFactory f)
Method for setting specific SerializerFactory to use
for constructing (bean) serializers. |
|
ObjectMapper |
setSerializerProvider(DefaultSerializerProvider p)
Method for setting specific SerializerProvider to use
for handling caching of JsonSerializer instances. |
|
ObjectMapper |
setSubtypeResolver(SubtypeResolver str)
Method for setting custom subtype resolver to use. |
|
ObjectMapper |
setTimeZone(TimeZone tz)
Method for overriding default TimeZone to use for formatting. |
|
ObjectMapper |
setTypeFactory(TypeFactory f)
Method that can be used to override TypeFactory instance
used by this mapper. |
|
ObjectMapper |
setVisibility(com.fasterxml.jackson.annotation.PropertyAccessor forMethod,
com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility visibility)
Convenience method that allows changing configuration for underlying VisibilityChecker s, to change details of what kinds of
properties are auto-detected. |
|
void |
setVisibilityChecker(VisibilityChecker<?> vc)
Method for setting currently configured visibility checker; object used for determining whether given property element (method, field, constructor) can be auto-detected or not. |
|
com.fasterxml.jackson.core.JsonParser |
treeAsTokens(com.fasterxml.jackson.core.TreeNode n)
Method for constructing a JsonParser out of JSON tree
representation. |
|
|
treeToValue(com.fasterxml.jackson.core.TreeNode n,
Class<T> valueType)
Convenience conversion method that will bind data given JSON tree contains into specific value (usually bean) type. |
|
|
valueToTree(Object fromValue)
Reverse of treeToValue(com.fasterxml.jackson.core.TreeNode, java.lang.Class ; given a value (usually bean), will
construct equivalent JSON Tree representation. |
|
com.fasterxml.jackson.core.Version |
version()
Method that will return version information stored in and read from jar that contains this class. |
|
ObjectWriter |
writer()
Convenience method for constructing ObjectWriter
with default settings. |
|
ObjectWriter |
writer(DateFormat df)
Factory method for constructing ObjectWriter that will
serialize objects using specified DateFormat ; or, if
null passed, using timestamp (64-bit number. |
|
ObjectWriter |
writer(FilterProvider filterProvider)
Factory method for constructing ObjectWriter that will
serialize objects using specified filter provider. |
|
ObjectWriter |
writer(com.fasterxml.jackson.core.FormatSchema schema)
Factory method for constructing ObjectWriter that will
pass specific schema object to JsonGenerator used for
writing content. |
|
ObjectWriter |
writer(com.fasterxml.jackson.core.PrettyPrinter pp)
Factory method for constructing ObjectWriter that will
serialize objects using specified pretty printer for indentation
(or if null, no pretty printer) |
|
ObjectWriter |
writer(SerializationFeature feature)
Factory method for constructing ObjectWriter with
specified feature enabled (compared to settings that this
mapper instance has). |
|
ObjectWriter |
writer(SerializationFeature first,
SerializationFeature... other)
Factory method for constructing ObjectWriter with
specified features enabled (compared to settings that this
mapper instance has). |
|
ObjectWriter |
writerWithDefaultPrettyPrinter()
Factory method for constructing ObjectWriter that will
serialize objects using the default pretty printer for indentation |
|
ObjectWriter |
writerWithType(Class<?> rootType)
Factory method for constructing ObjectWriter that will
serialize objects using specified root type, instead of actual
runtime type of value. |
|
ObjectWriter |
writerWithType(JavaType rootType)
Factory method for constructing ObjectWriter that will
serialize objects using specified root type, instead of actual
runtime type of value. |
|
ObjectWriter |
writerWithType(com.fasterxml.jackson.core.type.TypeReference<?> rootType)
Factory method for constructing ObjectWriter that will
serialize objects using specified root type, instead of actual
runtime type of value. |
|
ObjectWriter |
writerWithView(Class<?> serializationView)
Factory method for constructing ObjectWriter that will
serialize objects using specified JSON View (filter). |
|
void |
writeTree(com.fasterxml.jackson.core.JsonGenerator jgen,
JsonNode rootNode)
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(com.fasterxml.jackson.core.JsonGenerator jgen,
Object value)
Method that can be used to serialize any Java value as JSON output, using provided JsonGenerator . |
|
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. |
|
byte[] |
writeValueAsBytes(Object value)
Method that can be used to serialize any Java value as a byte array. |
|
String |
writeValueAsString(Object value)
Method that can be used to serialize any Java value as a String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final ClassIntrospector DEFAULT_INTROSPECTOR
protected static final AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR
protected static final VisibilityChecker<?> STD_VISIBILITY_CHECKER
protected static final BaseSettings DEFAULT_BASE
ObjectMapper
instances.
protected final com.fasterxml.jackson.core.JsonFactory _jsonFactory
JsonParser
and JsonGenerator
instances as necessary.
protected TypeFactory _typeFactory
JavaType
instances;
needed to allow modules to add more custom type handling
(mostly to support types of non-Java JVM languages)
protected InjectableValues _injectableValues
protected SubtypeResolver _subtypeResolver
protected final RootNameLookup _rootNames
protected final HashMap<ClassKey,Class<?>> _mixInAnnotations
Annotations associated with the value classes will be used to override annotations of the key class, associated with the same field or method. They can be further masked by sub-classes: you can think of it as injecting annotations between the target class and its sub-classes (or interfaces)
protected SerializationConfig _serializationConfig
protected DefaultSerializerProvider _serializerProvider
_serializerFactory
to allow
for constructing custom serializers.
Note: while serializers are only exposed SerializerProvider
,
mappers and readers need to access additional API defined by
DefaultSerializerProvider
protected SerializerFactory _serializerFactory
protected DeserializationConfig _deserializationConfig
protected DefaultDeserializationContext _deserializationContext
protected final ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _rootDeserializers
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.
Since version 1.5, these may are either "raw" deserializers (when no type information is needed for base type), or type-wrapped deserializers (if it is needed)
Constructor Detail |
---|
public ObjectMapper()
JsonFactory
as necessary, use
SerializerProvider
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.
public ObjectMapper(com.fasterxml.jackson.core.JsonFactory jf)
JsonFactory
for constructing necessary JsonParser
s and/or
JsonGenerator
s.
public ObjectMapper(com.fasterxml.jackson.core.JsonFactory jf, DefaultSerializerProvider sp, DefaultDeserializationContext dc)
JsonFactory
for constructing necessary JsonParser
s and/or
JsonGenerator
s, and uses given providers for accessing
serializers and deserializers.
jf
- JsonFactory to use: if null, a new MappingJsonFactory
will be constructedsp
- SerializerProvider to use: if null, a SerializerProvider
will be constructeddc
- Blueprint deserialization context instance to use for creating
actual context objects; if null, will construct standard
DeserializationContext
Method Detail |
---|
public com.fasterxml.jackson.core.Version version()
version
in interface com.fasterxml.jackson.core.Versioned
public ObjectMapper registerModule(Module module)
module
- Module to registerpublic SerializationConfig getSerializationConfig()
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
public DeserializationConfig getDeserializationConfig()
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
public ObjectMapper setSerializerFactory(SerializerFactory f)
SerializerFactory
to use
for constructing (bean) serializers.
public ObjectMapper setSerializerProvider(DefaultSerializerProvider p)
SerializerProvider
to use
for handling caching of JsonSerializer
instances.
public SerializerProvider getSerializerProvider()
public final void setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
public final void addMixInAnnotations(Class<?> target, Class<?> mixinSource)
mixinSource
are taken to override annotations
that target
(or its supertypes) has.
target
- Class (or interface) whose annotations to effectively overridemixinSource
- Class (or interface) whose annotations are to
be "added" to target's annotations, overriding as necessarypublic final Class<?> findMixInClassFor(Class<?> cls)
public final int mixInCount()
public VisibilityChecker<?> getVisibilityChecker()
public void setVisibilityChecker(VisibilityChecker<?> vc)
public ObjectMapper setVisibility(com.fasterxml.jackson.annotation.PropertyAccessor forMethod, com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility visibility)
VisibilityChecker
s, to change details of what kinds of
properties are auto-detected.
Basically short cut for doing:
mapper.setVisibilityChecker( mapper.getVisibilityChecker().withVisibility(forMethod, visibility) );one common use case would be to do:
mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY);which would make all member fields serializable without further annotations, instead of just public fields (default setting).
forMethod
- Type of property descriptor affected (field, getter/isGetter,
setter, creator)visibility
- Minimum visibility to require for the property descriptors of type
public SubtypeResolver getSubtypeResolver()
public ObjectMapper setSubtypeResolver(SubtypeResolver str)
public ObjectMapper setAnnotationIntrospector(AnnotationIntrospector ai)
AnnotationIntrospector
used by this
mapper instance for both serialization and deserialization
public ObjectMapper setPropertyNamingStrategy(PropertyNamingStrategy s)
public ObjectMapper setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include incl)
mapper.setSerializationConfig(mapper.getSerializationConfig().withSerializationInclusion(incl));
public ObjectMapper enableDefaultTyping()
enableObjectTyping(DefaultTyping.OBJECT_AND_NON_CONCRETE);
public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping dti)
enableObjectTyping(dti, JsonTypeInfo.As.WRAPPER_ARRAY);
public ObjectMapper enableDefaultTyping(ObjectMapper.DefaultTyping applicability, com.fasterxml.jackson.annotation.JsonTypeInfo.As includeAs)
JsonTypeInfo
).
applicability
- Defines kinds of types for which additional type information
is added; see ObjectMapper.DefaultTyping
for more information.public ObjectMapper enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping applicability, String propertyName)
JsonTypeInfo
) --
using "As.PROPERTY" inclusion mechanism and specified property name
to use for inclusion (default being "@class" since default type information
always uses class name as type identifier)
public ObjectMapper disableDefaultTyping()
JsonTypeInfo
) will have
additional embedded type information.
public ObjectMapper setDefaultTyping(TypeResolverBuilder<?> typer)
typer
- Type information inclusion handlerpublic void registerSubtypes(Class<?>... classes)
public void registerSubtypes(NamedType... types)
public TypeFactory getTypeFactory()
TypeFactory
instance.
public ObjectMapper setTypeFactory(TypeFactory f)
TypeFactory
instance
used by this mapper.
Note: will also set TypeFactory
that deserialization and
serialization config objects use.
public JavaType constructType(Type t)
JavaType
out of given
type (typically java.lang.Class
), but without explicit
context.
public ObjectMapper setNodeFactory(JsonNodeFactory f)
JsonNodeFactory
to use for
constructing root level tree nodes (via method
createObjectNode()
public ObjectMapper addHandler(DeserializationProblemHandler h)
DeserializationProblemHandler
to be used for handling specific problems during deserialization.
public ObjectMapper clearProblemHandlers()
DeserializationProblemHandler
s
instances from this mapper.
public void setFilters(FilterProvider filterProvider)
mapper.setFilters(mapper.getSerializationConfig().withFilters(filterProvider));
Note that usually it is better to use method writer(FilterProvider)
;
however, sometimes
this method is more convenient. For example, some frameworks only allow configuring
of ObjectMapper instances and not ObjectWriters.
public com.fasterxml.jackson.core.JsonFactory getJsonFactory()
JsonFactory
that this
mapper uses if it needs to construct JsonParser
s
and/or JsonGenerator
s.
getJsonFactory
in class com.fasterxml.jackson.core.ObjectCodec
JsonFactory
that this mapper uses when it needs to
construct Json parser and generatorspublic ObjectMapper setDateFormat(DateFormat dateFormat)
DateFormat
to use when serializing time
values as Strings, and deserializing from JSON Strings.
This is preferably to directly modifying SerializationConfig
and
DeserializationConfig
instances.
If you need per-request configuration, use writer(DateFormat)
to
create properly configured ObjectWriter
and use that; this because
ObjectWriter
s are thread-safe whereas ObjectMapper itself is only
thread-safe when configuring methods (such as this one) are NOT called.
public Object setHandlerInstantiator(HandlerInstantiator hi)
HandlerInstantiator
to use for creating
instances of handlers (such as serializers, deserializers, type and type
id resolvers), given a class.
hi
- Instantiator to use; if null, use the default implementationpublic ObjectMapper setInjectableValues(InjectableValues injectableValues)
InjectableValues
which used to find
values to inject.
public ObjectMapper setLocale(Locale l)
Locale.getDefault()
.
public ObjectMapper setTimeZone(TimeZone tz)
TimeZone.getDefault()
.
public ObjectMapper configure(MapperFeature f, boolean state)
public ObjectMapper configure(SerializationFeature f, boolean state)
public ObjectMapper configure(DeserializationFeature f, boolean state)
public ObjectMapper configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state)
JsonParser
feature for
JsonFactory
instance this object mapper uses.
This is method is basically a shortcut method for calling
JsonFactory.enable(com.fasterxml.jackson.core.JsonFactory.Feature)
on the shared
JsonFactory
this mapper uses (which is accessible
using getJsonFactory()
).
public ObjectMapper configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state)
JsonGenerator
feature for
JsonFactory
instance this object mapper uses.
This is method is basically a shortcut method for calling
JsonFactory.enable(com.fasterxml.jackson.core.JsonFactory.Feature)
on the shared
JsonFactory
this mapper uses (which is accessible
using getJsonFactory()
).
public ObjectMapper enable(MapperFeature... f)
MapperConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper disable(MapperFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper enable(DeserializationFeature feature)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper enable(DeserializationFeature first, DeserializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper disable(DeserializationFeature feature)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper disable(DeserializationFeature first, DeserializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper enable(SerializationFeature f)
DeserializationConfig
feature.
Modifies and returns this instance; no new object is created.
public ObjectMapper enable(SerializationFeature first, SerializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper disable(SerializationFeature f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public ObjectMapper disable(SerializationFeature first, SerializationFeature... f)
DeserializationConfig
features.
Modifies and returns this instance; no new object is created.
public boolean isEnabled(MapperFeature f)
public boolean isEnabled(SerializationFeature f)
public boolean isEnabled(DeserializationFeature f)
public boolean isEnabled(com.fasterxml.jackson.core.JsonFactory.Feature f)
getJsonFactory().isEnabled(f);
public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f)
getJsonFactory().isEnabled(f);
public boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f)
getJsonFactory().isEnabled(f);
public JsonNodeFactory getNodeFactory()
JsonNodeFactory
that this mapper will use when directly constructing
root JsonNode
instances for Trees.
Note: this is just a shortcut for calling
getDeserializationConfig().getNodeFactory()
public <T> T readValue(com.fasterxml.jackson.core.JsonParser jp, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
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.
readValue
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
readValue
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public final <T> T readValue(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.core.type.ResolvedType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
TypeFactory
.
readValue
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(com.fasterxml.jackson.core.JsonParser jp, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
readValues(JsonParser, ResolvedType)
.
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T extends com.fasterxml.jackson.core.TreeNode> T readTree(com.fasterxml.jackson.core.JsonParser jp) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
readTree
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonProcessingException
public <T> MappingIterator<T> readValues(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.core.type.ResolvedType valueType) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
Note that ObjectReader
has more complete set of variants.
readValues
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonProcessingException
public <T> MappingIterator<T> readValues(com.fasterxml.jackson.core.JsonParser jp, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
readValues(JsonParser, ResolvedType)
.
IOException
com.fasterxml.jackson.core.JsonProcessingException
public <T> MappingIterator<T> readValues(com.fasterxml.jackson.core.JsonParser jp, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
readValues
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonProcessingException
public <T> MappingIterator<T> readValues(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
readValues
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonProcessingException
public JsonNode readTree(InputStream in) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
in
- Input stream used to read JSON content
for building the JSON tree.
IOException
com.fasterxml.jackson.core.JsonProcessingException
public JsonNode readTree(Reader r) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
r
- Reader used to read JSON content
for building the JSON tree.
IOException
com.fasterxml.jackson.core.JsonProcessingException
public JsonNode readTree(String content) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
content
- JSON content to parse to build the JSON tree.
IOException
com.fasterxml.jackson.core.JsonProcessingException
public JsonNode readTree(byte[] content) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
content
- JSON content to parse to build the JSON tree.
IOException
com.fasterxml.jackson.core.JsonProcessingException
public JsonNode readTree(File file) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
file
- File of which contents to parse as JSON for building a tree instance
IOException
com.fasterxml.jackson.core.JsonProcessingException
public JsonNode readTree(URL source) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
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).
source
- URL to use for fetching contents to parse as JSON for building a tree instance
IOException
com.fasterxml.jackson.core.JsonProcessingException
public void writeValue(com.fasterxml.jackson.core.JsonGenerator jgen, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
JsonGenerator
.
writeValue
in class com.fasterxml.jackson.core.ObjectCodec
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
public void writeTree(com.fasterxml.jackson.core.JsonGenerator jgen, JsonNode rootNode) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
IOException
com.fasterxml.jackson.core.JsonProcessingException
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)
createObjectNode
in class com.fasterxml.jackson.core.ObjectCodec
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)
createArrayNode
in class com.fasterxml.jackson.core.ObjectCodec
public com.fasterxml.jackson.core.JsonParser treeAsTokens(com.fasterxml.jackson.core.TreeNode n)
JsonParser
out of JSON tree
representation.
treeAsTokens
in class com.fasterxml.jackson.core.ObjectCodec
n
- Root node of the tree that resulting parser will read frompublic <T> T treeToValue(com.fasterxml.jackson.core.TreeNode n, Class<T> valueType) throws com.fasterxml.jackson.core.JsonProcessingException
Equivalent to:
objectMapper.convertValue(n, valueClass);
treeToValue
in class com.fasterxml.jackson.core.ObjectCodec
com.fasterxml.jackson.core.JsonProcessingException
public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException
treeToValue(com.fasterxml.jackson.core.TreeNode, java.lang.Class)
; given a value (usually bean), will
construct equivalent JSON Tree representation. Functionally same
as if serializing value into JSON and parsing JSON as tree, but
more efficient.
T
- Actual node type; usually either basic JsonNode
or
ObjectNode
fromValue
- Bean value to convert
IllegalArgumentException
public boolean canSerialize(Class<?> type)
public boolean canDeserialize(JavaType type)
public <T> T readValue(File src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(File src, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(File src, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(URL src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(URL src, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(URL src, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(String content, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(String content, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(String content, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(Reader src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(Reader src, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(Reader src, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(InputStream src, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(InputStream src, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(byte[] src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(byte[] src, int offset, int len, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(byte[] src, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(byte[] src, int offset, int len, com.fasterxml.jackson.core.type.TypeReference valueTypeRef) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(byte[] src, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public <T> T readValue(byte[] src, int offset, int len, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
public void writeValue(File resultFile, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
public void writeValue(OutputStream out, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
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).
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
public void writeValue(Writer w, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
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).
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
public String writeValueAsString(Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
writeValue(Writer,Object)
with StringWriter
and constructing String, but more efficient.
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
public byte[] writeValueAsBytes(Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
writeValue(Writer,Object)
with ByteArrayOutputStream
and getting bytes, but more efficient.
Encoding used will be UTF-8.
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
public ObjectWriter writer()
ObjectWriter
with default settings.
public ObjectWriter writer(SerializationFeature feature)
ObjectWriter
with
specified feature enabled (compared to settings that this
mapper instance has).
public ObjectWriter writer(SerializationFeature first, SerializationFeature... other)
ObjectWriter
with
specified features enabled (compared to settings that this
mapper instance has).
public ObjectWriter writer(DateFormat df)
ObjectWriter
that will
serialize objects using specified DateFormat
; or, if
null passed, using timestamp (64-bit number.
public ObjectWriter writerWithView(Class<?> serializationView)
ObjectWriter
that will
serialize objects using specified JSON View (filter).
public ObjectWriter writerWithType(Class<?> rootType)
ObjectWriter
that will
serialize objects using specified root type, instead of actual
runtime type of value. Type must be a super-type of runtime
type.
public ObjectWriter writerWithType(JavaType rootType)
ObjectWriter
that will
serialize objects using specified root type, instead of actual
runtime type of value. Type must be a super-type of runtime type.
public ObjectWriter writerWithType(com.fasterxml.jackson.core.type.TypeReference<?> rootType)
ObjectWriter
that will
serialize objects using specified root type, instead of actual
runtime type of value. Type must be a super-type of runtime type.
public ObjectWriter writer(com.fasterxml.jackson.core.PrettyPrinter pp)
ObjectWriter
that will
serialize objects using specified pretty printer for indentation
(or if null, no pretty printer)
public ObjectWriter writerWithDefaultPrettyPrinter()
ObjectWriter
that will
serialize objects using the default pretty printer for indentation
public ObjectWriter writer(FilterProvider filterProvider)
ObjectWriter
that will
serialize objects using specified filter provider.
public ObjectWriter writer(com.fasterxml.jackson.core.FormatSchema schema)
ObjectWriter
that will
pass specific schema object to JsonGenerator
used for
writing content.
schema
- Schema to pass to generatorpublic ObjectReader reader()
ObjectReader
with
default settings. Note that the resulting instance is NOT usable as is,
without defining expected value type.
public ObjectReader reader(DeserializationFeature feature)
ObjectReader
with
specified feature enabled (compared to settings that this
mapper instance has).
Note that the resulting instance is NOT usable as is,
without defining expected value type.
public ObjectReader reader(DeserializationFeature first, DeserializationFeature... other)
ObjectReader
with
specified features enabled (compared to settings that this
mapper instance has).
Note that the resulting instance is NOT usable as is,
without defining expected value type.
public ObjectReader readerForUpdating(Object valueToUpdate)
ObjectReader
that will
update given Object (usually Bean, but can be a Collection or Map
as well, but NOT an array) with JSON data. Deserialization occurs
normally except that the root-level value in JSON is not used for
instantiating a new object; instead give updateable object is used
as root.
Runtime type of value object is used for locating deserializer,
unless overridden by other factory methods of ObjectReader
public ObjectReader reader(JavaType type)
ObjectReader
that will
read or update instances of specified type
public ObjectReader reader(Class<?> type)
ObjectReader
that will
read or update instances of specified type
public ObjectReader reader(com.fasterxml.jackson.core.type.TypeReference<?> type)
ObjectReader
that will
read or update instances of specified type
public ObjectReader reader(JsonNodeFactory f)
ObjectReader
that will
use specified JsonNodeFactory
for constructing JSON trees.
public ObjectReader reader(com.fasterxml.jackson.core.FormatSchema schema)
ObjectReader
that will
pass specific schema object to JsonParser
used for
reading content.
schema
- Schema to pass to parserpublic ObjectReader reader(InjectableValues injectableValues)
ObjectReader
that will
use specified injectable values.
injectableValues
- Injectable values to usepublic ObjectReader readerWithView(Class<?> view)
ObjectReader
that will
deserialize objects using specified JSON View (filter).
public <T> T convertValue(Object fromValue, Class<T> toValueType) throws IllegalArgumentException
IllegalArgumentException
- If conversion fails due to incompatible type;
if so, root cause will contain underlying checked exception data binding
functionality threwpublic <T> T convertValue(Object fromValue, com.fasterxml.jackson.core.type.TypeReference toValueTypeRef) throws IllegalArgumentException
IllegalArgumentException
public <T> T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException
IllegalArgumentException
protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException
writeValue
and
readValue
methods.
IllegalArgumentException
public JsonSchema generateJsonSchema(Class<?> t) throws JsonMappingException
t
- The class to generate schema for
JsonMappingException
protected DefaultSerializerProvider _serializerProvider(SerializationConfig config)
SerializerProvider
to use for serialization.
protected com.fasterxml.jackson.core.PrettyPrinter _defaultPrettyPrinter()
protected final void _configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator jgen, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
protected final void _configAndWriteValue(com.fasterxml.jackson.core.JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonGenerationException
JsonMappingException
protected final DefaultDeserializationContext createDeserializationContext(com.fasterxml.jackson.core.JsonParser jp, DeserializationConfig cfg)
DeserializationContext
for deserializing a single root value.
Can be overridden if a custom context is needed.
protected Object _readValue(DeserializationConfig cfg, com.fasterxml.jackson.core.JsonParser jp, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
protected Object _readMapAndClose(com.fasterxml.jackson.core.JsonParser jp, JavaType valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
protected com.fasterxml.jackson.core.JsonToken _initForReading(com.fasterxml.jackson.core.JsonParser jp) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
- if the underlying input source has problems during
parsing
com.fasterxml.jackson.core.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)protected Object _unwrapAndDeserialize(com.fasterxml.jackson.core.JsonParser jp, DeserializationContext ctxt, DeserializationConfig config, JavaType rootType, JsonDeserializer<Object> deser) throws IOException, com.fasterxml.jackson.core.JsonParseException, JsonMappingException
IOException
com.fasterxml.jackson.core.JsonParseException
JsonMappingException
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException
JsonMappingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |