Note
about the only configurable setting currently is ability to filter out entries with specified names.
| Modifier and Type | Field and Description |
|---|---|
| protected final Object | _filterId
Id of the property filter to use, if any; null if none. |
| protected final Set | _ignoredEntries
Set of entries to omit during serialization, if any |
| protected final Set | _includedEntries
Set of entries to include during serialization, if null, it is ignored, empty will include nothing. |
| protected final IgnorePropertiesUtil. | _inclusionChecker
Helper object used for name-based filtering |
| protected ValueSerializer | _keySerializer
Key serializer to use, if it can be statically determined |
| protected final JavaType | _keyType
Declared type of keys |
| 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 |
| protected final boolean | _suppressNulls
Flag that indicates what to do with `null` values, distinct from
handling of |
| protected ValueSerializer | _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 | |
| protected static final JavaType |
| Access | Constructor and Description |
|---|---|
| protected | MapSerializer(Set<String> ignoredEntries, Set<String> includedEntries, JavaType keyType, JavaType valueType, boolean valueTypeIsStatic, TypeSerializer vts, ValueSerializer<?> keySerializer, ValueSerializer<?> valueSerializer)
|
| protected | MapSerializer(MapSerializer src, BeanProperty property, ValueSerializer<?> keySerializer, ValueSerializer<?> valueSerializer, Set<String> ignoredEntries, Set<String> includedEntries)
|
| protected | MapSerializer(MapSerializer src, TypeSerializer vts, Object suppressableValue, boolean suppressNulls)
|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| private final ValueSerializer | |
| protected boolean | |
| protected Map | |
| protected MapSerializer | _withValueTypeSerializer(TypeSerializer vts)
Implements abstract tools. Method that needs to be implemented to allow construction of a new
serializer object with given |
| protected void | |
| public void | acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
Overrides tools. Implements tools. Default implementation specifies no format. |
| public static MapSerializer | construct(JavaType mapType, boolean staticValueType, TypeSerializer vts, ValueSerializer<Object> keySerializer, ValueSerializer<Object> valueSerializer, Object filterId, Set<String> ignoredEntries, Set<String> includedEntries)
|
| public ValueSerializer | createContextual(SerializationContext ctxt, BeanProperty property)
Overrides tools. Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property (or, for root values, in which case `null` is passed). |
| public ValueSerializer | getContentSerializer()
Implements abstract tools. 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 tools. Accessor for finding declared (static) element type for type this serializer is used for. |
| public ValueSerializer | |
| public boolean | hasSingleElement(Map<?, ?> value)
Implements abstract tools. Method called to determine if the given value (of type handled by this serializer) contains exactly one element. |
| public boolean | isEmpty(SerializationContext prov, Map<?, ?> value)
Implements abstract tools. 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, JsonGenerator gen, SerializationContext provider)
Implements abstract tools. Method that can be called to ask implementation to serialize values of type this serializer handles. |
| public void | serializeEntries(Map<?, ?> value, JsonGenerator gen, SerializationContext 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) Note
|
| public void | serializeEntriesUsing(Map<?, ?> value, JsonGenerator gen, SerializationContext provider, ValueSerializer<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(SerializationContext 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 | serializeFilteredEntries(Map<?, ?> value, JsonGenerator gen, SerializationContext 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, SerializationContext provider, Object suppressableValue)
Serialization method called when exclusion filtering needs to be applied. |
| public void | serializeTypedEntries(Map<?, ?> value, JsonGenerator gen, SerializationContext provider, Object suppressableValue)
Note
|
| public void | serializeWithoutTypeInfo(Map<?, ?> value, JsonGenerator gen, SerializationContext ctxt)
General-purpose serialization for contents without writing object type. |
| public void | serializeWithType(Map<?, ?> value, JsonGenerator gen, SerializationContext ctxt, TypeSerializer typeSer)
Overrides tools. 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)
Mutant factory for constructing an instance with different inclusion strategy for content (Map values). |
| public MapSerializer | withFilterId(Object filterId)
Overrides tools. Mutant factory method that is called if contextual configuration indicates that
a specific filter (as specified by |
| protected MapSerializer | withResolved(BeanProperty property, ValueSerializer<?> keySerializer, ValueSerializer<?> valueSerializer, Set<String> ignored, Set<String> included, boolean sortKeys)
|
| _filterId | back to summary |
|---|---|
| protected final Object _filterId Id of the property filter to use, if any; null if none. | |
| _ignoredEntries | back to summary |
|---|---|
| protected final Set<String> _ignoredEntries Set of entries to omit during serialization, if any | |
| _includedEntries | back to summary |
|---|---|
| protected final Set<String> _includedEntries Set of entries to include during serialization, if null, it is ignored, empty will include nothing.
| |
| _inclusionChecker | back to summary |
|---|---|
| protected final IgnorePropertiesUtil. Helper object used for name-based filtering
| |
| _keySerializer | back to summary |
|---|---|
| protected ValueSerializer<Object> _keySerializer Key serializer to use, if it can be statically determined | |
| _keyType | back to summary |
|---|---|
| protected final JavaType _keyType Declared type of keys | |
| _sortKeys | back to summary |
|---|---|
| protected final boolean _sortKeys Flag set if output is forced to be sorted by keys (usually due to annotation). | |
| _suppressableValue | back to summary |
|---|---|
| protected final Object _suppressableValue Value that indicates suppression mechanism to use for values contained;
either "filter" (of which | |
| _suppressNulls | back to summary |
|---|---|
| protected final boolean _suppressNulls Flag that indicates what to do with `null` values, distinct from
handling of | |
| _valueSerializer | back to summary |
|---|---|
| protected ValueSerializer<Object> _valueSerializer Value serializer to use, if it can be statically determined | |
| _valueType | back to summary |
|---|---|
| protected final JavaType _valueType Declared type of contained values | |
| _valueTypeIsStatic | back to summary |
|---|---|
| protected final boolean _valueTypeIsStatic Whether static types should be used for serialization of values or not (if not, dynamic runtime type is used) | |
| _valueTypeSerializer | back to summary |
|---|---|
| protected final TypeSerializer _valueTypeSerializer Type identifier serializer used for values, if any. | |
| MARKER_FOR_EMPTY | back to summary |
|---|---|
| public static final Object MARKER_FOR_EMPTY | |
| UNSPECIFIED_TYPE | back to summary |
|---|---|
| protected static final JavaType UNSPECIFIED_TYPE | |
| MapSerializer | back to summary |
|---|---|
protected MapSerializer(Set<String> ignoredEntries, Set<String> includedEntries, JavaType keyType, JavaType valueType, boolean valueTypeIsStatic, TypeSerializer vts, ValueSerializer<?> keySerializer, ValueSerializer<?> valueSerializer)
| |
| MapSerializer | back to summary |
|---|---|
protected MapSerializer(MapSerializer src, BeanProperty property, ValueSerializer<?> keySerializer, ValueSerializer<?> valueSerializer, Set<String> ignoredEntries, Set<String> includedEntries)
| |
| MapSerializer | back to summary |
|---|---|
| protected MapSerializer(MapSerializer src, TypeSerializer vts, Object suppressableValue, boolean suppressNulls) | |
| MapSerializer | back to summary |
|---|---|
| protected MapSerializer(MapSerializer src, Object filterId, boolean sortKeys) | |
| _ensureOverride | back to summary |
|---|---|
| protected void _ensureOverride(String method) | |
| _findSerializer | back to summary |
|---|---|
| private final ValueSerializer | |
| _hasNullKey | back to summary |
|---|---|
| protected boolean _hasNullKey(Map<?, ?> input) | |
| _orderEntries | back to summary |
|---|---|
| protected Map | |
| _withValueTypeSerializer | back to summary |
|---|---|
| protected MapSerializer _withValueTypeSerializer(TypeSerializer vts) Implements abstract tools. Doc from tools. Method that needs to be implemented to allow construction of a new
serializer object with given
| |
| _writeNullKeyedEntry | back to summary |
|---|---|
| protected void _writeNullKeyedEntry(JsonGenerator g, SerializationContext ctxt, Object value) throws JacksonException | |
| acceptJsonFormatVisitor | back to summary |
|---|---|
| public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) Overrides tools. Implements tools. Doc from tools. Default implementation specifies no format. This behavior is usually overriden by custom serializers.
| |
| construct | back to summary |
|---|---|
| public static MapSerializer construct(JavaType mapType, boolean staticValueType, TypeSerializer vts, ValueSerializer<Object> keySerializer, ValueSerializer<Object> valueSerializer, Object filterId, Set<String> ignoredEntries, Set<String> includedEntries) | |
| createContextual | back to summary |
|---|---|
| public ValueSerializer Overrides tools. Doc from tools. Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property (or, for root values, in which case `null` is passed). Note that instance that this method is called on is typically shared one and as a result method should NOT modify this instance but rather construct and return a new instance. This instance should only be returned as-is, in case it is already suitable for use. Note that method is only called once per POJO property, and for the first usage as root value serializer; it is not called for every serialization, as doing that would have significant performance impact; most serializers cache contextual instances for future use.
| |
| getContentSerializer | back to summary |
|---|---|
| public ValueSerializer Implements abstract tools. Doc from tools. 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.
Note that for dynamic types this may return null; if so,
caller has to instead use
| |
| getContentType | back to summary |
|---|---|
| public JavaType getContentType() Implements abstract tools. Doc from tools. Accessor for finding declared (static) element type for type this serializer is used for.
| |
| getKeySerializer | back to summary |
|---|---|
| public ValueSerializer Accessor for currently assigned key serializer. Note that
this may return null during construction of | |
| hasSingleElement | back to summary |
|---|---|
| public boolean hasSingleElement(Map<?, ?> value) Implements abstract tools. Doc from tools. Method called to determine if the given value (of type handled by this serializer) contains exactly one element. Note although it might seem sensible to instead define something like "getElementCount()" method, this would not work well for containers that do not keep track of size (like linked lists may not).
Note, too, that this method is only called by serializer
itself; and specifically is not used for non-array/collection types
like
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty(SerializationContext prov, Map<?, ?> value) Implements abstract tools. Doc from tools. Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values). Default implementation will consider only null values to be empty.
| |
| serialize | back to summary |
|---|---|
| public void serialize(Map<?, ?> value, JsonGenerator gen, SerializationContext provider) throws JacksonException Implements abstract tools. Doc from tools. Method that can be called to ask implementation to serialize values of type this serializer handles.
| |
| serializeEntries | back to summary |
|---|---|
| public void serializeEntries(Map<?, ?> value, JsonGenerator gen, SerializationContext provider) throws JacksonException 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) Note
| |
| serializeEntriesUsing | back to summary |
|---|---|
| public void serializeEntriesUsing(Map<?, ?> value, JsonGenerator gen, SerializationContext provider, ValueSerializer<Object> ser) throws JacksonException 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. Note
| |
| serializeFilteredAnyProperties | back to summary |
|---|---|
| public void serializeFilteredAnyProperties(SerializationContext provider, JsonGenerator gen, Object bean, Map<?, ?> value, PropertyFilter filter, Object suppressableValue) throws JacksonException Helper method used when we have a JSON Filter to use AND contents are "any properties" of a POJO. Note
| |
| serializeFilteredEntries | back to summary |
|---|---|
| public void serializeFilteredEntries(Map<?, ?> value, JsonGenerator gen, SerializationContext provider, PropertyFilter filter, Object suppressableValue) throws JacksonException Helper method used when we have a JSON Filter to use for potentially filtering out Map entries. Note
| |
| serializeOptionalFields | back to summary |
|---|---|
| public void serializeOptionalFields(Map<?, ?> value, JsonGenerator gen, SerializationContext provider, Object suppressableValue) throws JacksonException Serialization method called when exclusion filtering needs to be applied. Note
| |
| serializeTypedEntries | back to summary |
|---|---|
| public void serializeTypedEntries(Map<?, ?> value, JsonGenerator gen, SerializationContext provider, Object suppressableValue) throws JacksonException Note
| |
| serializeWithoutTypeInfo | back to summary |
|---|---|
| public void serializeWithoutTypeInfo(Map<?, ?> value, JsonGenerator gen, SerializationContext ctxt) throws JacksonException General-purpose serialization for contents without writing object type. Will suppress, filter and use custom serializers. Note Public only since it also is called by | |
| serializeWithType | back to summary |
|---|---|
| public void serializeWithType(Map<?, ?> value, JsonGenerator gen, SerializationContext ctxt, TypeSerializer typeSer) throws JacksonException Overrides tools. Doc from tools. 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.
Default implementation will throw For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like: // note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen);and implementations for type serialized as JSON Arrays or Objects would differ slightly, as START-ARRAY/END-ARRAY and
START-OBJECT/END-OBJECT pairs
need to be properly handled with respect to serializing of contents.
| |
| withContentInclusion | back to summary |
|---|---|
| public MapSerializer withContentInclusion(Object suppressableValue, boolean suppressNulls) Mutant factory for constructing an instance with different inclusion strategy for content (Map values). Note only | |
| withFilterId | back to summary |
|---|---|
| public MapSerializer withFilterId(Object filterId) Overrides tools. Doc from tools. Mutant factory method that is called if contextual configuration indicates that
a specific filter (as specified by
Default implementation simply returns
| |
| withResolved | back to summary |
|---|---|
| protected MapSerializer withResolved(BeanProperty property, ValueSerializer<?> keySerializer, ValueSerializer<?> valueSerializer, Set<String> ignored, Set<String> included, boolean sortKeys) | |