Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.ser.std

public Class MapSerializer

extends ContainerSerializer<Map<?, ?>>
implements ContextualSerializer
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.ser.ContextualSerializer
Annotations
@JacksonStdImpl
Imports
java.io.IOException, java.lang.reflect.Type, java.util.*, com.fasterxml.jackson.annotation.JsonFormat, .JsonInclude, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.type.WritableTypeId, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.annotation.JacksonStdImpl, com.fasterxml.jackson.databind.introspect.AnnotatedMember, com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, .JsonMapFormatVisitor, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.ser.ContainerSerializer, .ContextualSerializer, .PropertyFilter, com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap, com.fasterxml.jackson.databind.type.TypeFactory, com.fasterxml.jackson.databind.util.ArrayBuilders, .BeanUtil, .ClassUtil, .IgnorePropertiesUtil

Deprecated

as a consequence of ContainerSerializer being deprecated. See corresponding docs for further information.

Standard serializer implementation for serializing {link java.util.Map} types.

Note

about the only configurable setting currently is ability to filter out entries with specified names.

Field Summary

Modifier and TypeField and Description
protected PropertySerializerMap
_dynamicValueSerializers

If value type cannot be statically determined, mapping from runtime value types to serializers are stored in this object.

protected final Object
_filterId

Id of the property filter to use, if any; null if none.

protected final Set<String>
_ignoredEntries

Set of entries to omit during serialization, if any

protected final Set<String>
_includedEntries

Set of entries to include during serialization, if null, it is ignored, empty will include nothing.

protected final IgnorePropertiesUtil.Checker
_inclusionChecker

Helper object used for name-based filtering

protected JsonSerializer<Object>
_keySerializer

Key serializer to use, if it can be statically determined

protected final JavaType
_keyType

Declared type of keys

protected final BeanProperty
_property

Map-valued property being serialized with this instance

protected final boolean
_sortKeys

Flag set if output is forced to be sorted by keys (usually due to annotation).

protected final Object
_suppressableValue

Value that indicates suppression mechanism to use for values contained; either "filter" (of which equals() is called), or marker value of MARKER_FOR_EMPTY, or null to indicate no filtering for non-null values.

protected final boolean
_suppressNulls

Flag that indicates what to do with `null` values, distinct from handling of _suppressableValue

protected JsonSerializer<Object>
_valueSerializer

Value serializer to use, if it can be statically determined

protected final JavaType
_valueType

Declared type of contained values

protected final boolean
_valueTypeIsStatic

Whether static types should be used for serialization of values or not (if not, dynamic runtime type is used)

protected final TypeSerializer
_valueTypeSerializer

Type identifier serializer used for values, if any.

public static final Object
private static final long
protected static final JavaType

Constructor Summary

AccessConstructor and Description
protected
MapSerializer(Set<String> ignoredEntries, Set<String> includedEntries, JavaType keyType, JavaType valueType, boolean valueTypeIsStatic, TypeSerializer vts, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer)

protected
MapSerializer(Set<String> ignoredEntries, JavaType keyType, JavaType valueType, boolean valueTypeIsStatic, TypeSerializer vts, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer)

Deprecated in 2.12, remove from 3.0
protected
MapSerializer(MapSerializer src, BeanProperty property, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer, Set<String> ignoredEntries, Set<String> includedEntries)

Deprecated as a consequence of MapSerializer being deprecated.
protected
MapSerializer(MapSerializer src, BeanProperty property, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer, Set<String> ignoredEntries)

Deprecated in 2.12, remove from 3.0
protected
MapSerializer(MapSerializer src, TypeSerializer vts, Object suppressableValue, boolean suppressNulls)

Deprecated as a consequence of MapSerializer being deprecated.
protected
MapSerializer(MapSerializer src, Object filterId, boolean sortKeys)

Deprecated as a consequence of MapSerializer being deprecated.
protected
MapSerializer(MapSerializer src, TypeSerializer vts, Object suppressableValue)

Deprecated // since 2.9

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
_ensureOverride()

Deprecated
protected final JsonSerializer<Object>
protected final JsonSerializer<Object>
private final JsonSerializer<Object>
protected boolean
_hasNullKey(Map<?, ?> input)

protected Map<?, ?>
_orderEntries(Map<?, ?> input, JsonGenerator gen, SerializerProvider provider)

public MapSerializer
_withValueTypeSerializer(TypeSerializer vts)

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer._withValueTypeSerializer.

Deprecated as a consequence of MapSerializer being deprecated.
Method that needs to be implemented to allow construction of a new serializer object with given TypeSerializer, used when addition type information is to be embedded.
protected void
public void
public static MapSerializer
construct(Set<String> ignoredEntries, Set<String> includedEntries, JavaType mapType, boolean staticValueType, TypeSerializer vts, JsonSerializer<Object> keySerializer, JsonSerializer<Object> valueSerializer, Object filterId)

Deprecated as a consequence of MapSerializer being deprecated.
public static MapSerializer
construct(Set<String> ignoredEntries, JavaType mapType, boolean staticValueType, TypeSerializer vts, JsonSerializer<Object> keySerializer, JsonSerializer<Object> valueSerializer, Object filterId)

Deprecated as a consequence of MapSerializer being deprecated.
public static MapSerializer
construct(String[] ignoredList, JavaType mapType, boolean staticValueType, TypeSerializer vts, JsonSerializer<Object> keySerializer, JsonSerializer<Object> valueSerializer, Object filterId)

Deprecated Since 2.8 use the other overload
public JsonSerializer<?>
createContextual(SerializerProvider
Serializer provider to use for accessing config, other serializers
provider
,
BeanProperty
Method or field that represents the property (and is used to access value to serialize). Should be available; but there may be cases where caller cannot provide it and null is passed instead (in which case impls usually pass 'this' serializer as is)
property
)

Implements com.fasterxml.jackson.databind.ser.ContextualSerializer.createContextual.

Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property.
public JsonSerializer<?>
getContentSerializer()

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer.getContentSerializer.

Accessor for serializer used for serializing contents (List and array elements, Map values etc) of the container for which this serializer is used, if it is known statically.
public JavaType
getContentType()

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer.getContentType.

Accessor for finding declared (static) element type for type this serializer is used for.
public JsonSerializer<?>
getKeySerializer()

Accessor for currently assigned key serializer.

public JsonNode
getSchema(SerializerProvider
The serializer provider.
provider
,
Type
A hint about the type.
typeHint
)

Overrides com.fasterxml.jackson.databind.ser.std.StdSerializer.getSchema.

Implements com.fasterxml.jackson.databind.jsonschema.SchemaAware.getSchema.

Deprecated Since 2.15
Default implementation simply claims type is "string"; usually overriden by custom serializers.
public boolean
hasSingleElement(Map<?, ?> value)

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer.hasSingleElement.

Method called to determine if the given value (of type handled by this serializer) contains exactly one element.
public boolean
isEmpty(SerializerProvider prov, Map<?, ?> value)

Overrides com.fasterxml.jackson.databind.JsonSerializer.isEmpty.

Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).
public void
serialize(Map<?, ?>
Value to serialize; can not be null.
value
,
JsonGenerator
Generator used to output resulting Json content
gen
,
SerializerProvider
Provider that can be used to get serializers for serializing Objects value contains, if any.
provider
)

Implements abstract com.fasterxml.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.
public void
serializeFields(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider)

General-purpose serialization for contents, where we do not necessarily know the value serialization, but we do know that no value suppression is needed (which simplifies processing a bit)

public void
serializeFieldsUsing(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider, JsonSerializer<Object> ser)

Method called to serialize fields, when the value type is statically known, so that value serializer is passed and does not need to be fetched from provider.

public void
serializeFilteredAnyProperties(SerializerProvider provider, JsonGenerator gen, Object
Enclosing POJO that has any-getter used to obtain "any properties"
bean
,
Map<?, ?> value, PropertyFilter filter, Object suppressableValue)

Helper method used when we have a JSON Filter to use AND contents are "any properties" of a POJO.

public void
serializeFilteredFields(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider, PropertyFilter filter, Object suppressableValue)

Helper method used when we have a JSON Filter to use for potentially filtering out Map entries.

public void
serializeOptionalFields(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider, Object suppressableValue)

Serialization method called when exclusion filtering needs to be applied.

public void
serializeTypedFields(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider, Object suppressableValue)

public void
serializeWithoutTypeInfo(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider)

General-purpose serialization for contents without writing object type.

public void
serializeWithType(Map<?, ?>
Value to serialize; can not be null.
value
,
JsonGenerator
Generator used to output resulting Json content
gen
,
SerializerProvider
Provider that can be used to get serializers for serializing Objects value contains, if any.
provider
,
TypeSerializer
Type serializer to use for including type information
typeSer
)

Overrides com.fasterxml.jackson.databind.JsonSerializer.serializeWithType.

Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.
public MapSerializer
withContentInclusion(Object suppressableValue, boolean suppressNulls)

Deprecated as a consequence of MapSerializer being deprecated.
Mutant factory for constructing an instance with different inclusion strategy for content (Map values).
public MapSerializer
withContentInclusion(Object suppressableValue)

Deprecated since 2.9
public MapSerializer
withFilterId(Object filterId)

Overrides com.fasterxml.jackson.databind.JsonSerializer.withFilterId.

Deprecated as a consequence of MapSerializer being deprecated.
Mutant factory method that is called if contextual configuration indicates that a specific filter (as specified by filterId) is to be used for serialization.
public MapSerializer
withResolved(BeanProperty property, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer, Set<String> ignored, Set<String> included, boolean sortKeys)

Deprecated as a consequence of MapSerializer being deprecated.
public MapSerializer
withResolved(BeanProperty property, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer, Set<String> ignored, boolean sortKeys)

Deprecated as a consequence of MapSerializer being deprecated.
Inherited from com.fasterxml.jackson.databind.ser.ContainerSerializer:
hasContentTypeAnnotationwithValueTypeSerializer