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

public abstract Class AsArraySerializerBase<T>

extends ContainerSerializer<T>
implements ContextualSerializer
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.ser.ContextualSerializer
Known Direct Subclasses
com.fasterxml.jackson.databind.ser.std.CollectionSerializer, com.fasterxml.jackson.databind.ser.std.EnumSetSerializer, com.fasterxml.jackson.databind.ser.std.IterableSerializer, com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer, com.fasterxml.jackson.databind.ser.impl.IteratorSerializer
Annotations
@SuppressWarnings:serial
Imports
java.io.IOException, java.lang.reflect.Type, java.util.Objects, com.fasterxml.jackson.annotation.JsonFormat, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.type.WritableTypeId, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.introspect.AnnotatedMember, com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.node.ObjectNode, com.fasterxml.jackson.databind.ser.ContainerSerializer, .ContextualSerializer, com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap

References Deprecated

ContainerSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Base class for serializers that will output contents as JSON arrays; typically serializers used for java.util.Collection and array types.

Field Summary

Modifier and TypeField and Description
protected PropertySerializerMap
_dynamicSerializers

If element type cannot be statically determined, mapping from runtime type to serializer is handled using this object

protected final JsonSerializer<Object>
_elementSerializer

Value serializer to use, if it can be statically determined

protected final JavaType
protected final BeanProperty
_property

Collection-valued property being serialized with this instance

protected final boolean
protected final Boolean
_unwrapSingle

Setting for specific local override for "unwrap single element arrays": true for enable unwrapping, false for preventing it, `null` for using global configuration.

protected final TypeSerializer
_valueTypeSerializer

Type serializer used for values, if any.

Constructor Summary

AccessConstructor and Description
protected
AsArraySerializerBase(Class<?> cls, JavaType et, boolean staticTyping, TypeSerializer vts, JsonSerializer<Object> elementSerializer)

Non-contextual, "blueprint" constructor typically called when the first instance is created, without knowledge of property it was used via.

protected
AsArraySerializerBase(Class<?> cls, JavaType et, boolean staticTyping, TypeSerializer vts, BeanProperty property, JsonSerializer<Object> elementSerializer)
Deprecated Since 2.6 Use variants that either take 'src', or do NOT pass BeanProperty

protected
AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, BeanProperty property, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)

General purpose constructor.

protected
AsArraySerializerBase(AsArraySerializerBase<?> src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)
References Deprecated AsArraySerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

protected
AsArraySerializerBase(AsArraySerializerBase<?> src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer)
Deprecated since 2.6: use the overloaded method that takes 'unwrapSingle'

Method Summary

Modifier and TypeMethod and Description
protected final JsonSerializer<Object>
protected final JsonSerializer<Object>
public void
public JsonSerializer<?>
createContextual(SerializerProvider
Serializer provider to use for accessing config, other serializers
serializers
,
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.

This method is needed to resolve contextual annotations like per-property overrides, as well as do recursive call to createContextual of content serializer, if known statically.

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 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 void
serialize(T
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.

protected abstract void
public void
serializeWithType(T
Value to serialize; can not be null.
value
,
JsonGenerator
Generator used to output resulting Json content
g
,
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 final AsArraySerializerBase<T>
withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer)
Deprecated since 2.6: use the overloaded method that takes 'unwrapSingle'

public abstract AsArraySerializerBase<T>
withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)
References Deprecated AsArraySerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

Inherited from com.fasterxml.jackson.databind.ser.ContainerSerializer:
_withValueTypeSerializerhasContentTypeAnnotationhasSingleElementwithValueTypeSerializer

Field Detail

_dynamicSerializersback to summary
protected PropertySerializerMap _dynamicSerializers

If element type cannot be statically determined, mapping from runtime type to serializer is handled using this object

_elementSerializerback to summary
protected final JsonSerializer<Object> _elementSerializer

Value serializer to use, if it can be statically determined

_elementTypeback to summary
protected final JavaType _elementType
_propertyback to summary
protected final BeanProperty _property

Collection-valued property being serialized with this instance

_staticTypingback to summary
protected final boolean _staticTyping
_unwrapSingleback to summary
protected final Boolean _unwrapSingle

Setting for specific local override for "unwrap single element arrays": true for enable unwrapping, false for preventing it, `null` for using global configuration.

Since
2.6
_valueTypeSerializerback to summary
protected final TypeSerializer _valueTypeSerializer

Type serializer used for values, if any.

Constructor Detail

AsArraySerializerBaseback to summary
protected AsArraySerializerBase(Class<?> cls, JavaType et, boolean staticTyping, TypeSerializer vts, JsonSerializer<Object> elementSerializer)

Non-contextual, "blueprint" constructor typically called when the first instance is created, without knowledge of property it was used via.

Since
2.6
AsArraySerializerBaseback to summary
protected AsArraySerializerBase(Class<?> cls, JavaType et, boolean staticTyping, TypeSerializer vts, BeanProperty property, JsonSerializer<Object> elementSerializer)

Deprecated

Since 2.6 Use variants that either take 'src', or do NOT pass BeanProperty

Annotations
@Deprecated
AsArraySerializerBaseback to summary
protected AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, BeanProperty property, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)

General purpose constructor. Use contextual constructors, if possible.

Annotations
@SuppressWarnings:unchecked
Since
2.12
AsArraySerializerBaseback to summary
protected AsArraySerializerBase(AsArraySerializerBase<?> src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)

References Deprecated

AsArraySerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:unchecked
AsArraySerializerBaseback to summary
protected AsArraySerializerBase(AsArraySerializerBase<?> src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer)

Deprecated

since 2.6: use the overloaded method that takes 'unwrapSingle'

Annotations
@Deprecated

Method Detail

_findAndAddDynamicback to summary
protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException
_findAndAddDynamicback to summary
protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, JavaType type, SerializerProvider provider) throws JsonMappingException
acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException

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

Implements com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable.acceptJsonFormatVisitor.

Doc from com.fasterxml.jackson.databind.ser.std.StdSerializer.acceptJsonFormatVisitor.

Default implementation specifies no format. This behavior is usually overriden by custom serializers.

Parameters
typeHint:JavaType

Doc from com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable.acceptJsonFormatVisitor.

Type of element (entity like property) being visited

Annotations
@Override
createContextualback to summary
public JsonSerializer<?> createContextual(SerializerProvider serializers, BeanProperty property) throws JsonMappingException

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

This method is needed to resolve contextual annotations like per-property overrides, as well as do recursive call to createContextual of content serializer, if known statically.

Parameters
serializers:SerializerProvider

Doc from com.fasterxml.jackson.databind.ser.ContextualSerializer.createContextual.

Serializer provider to use for accessing config, other serializers

property:BeanProperty

Doc from com.fasterxml.jackson.databind.ser.ContextualSerializer.createContextual.

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)

Returns:JsonSerializer<?>

Doc from com.fasterxml.jackson.databind.ser.ContextualSerializer.createContextual.

Serializer to use for serializing values of specified property; may be this instance or a new instance.

Annotations
@Override
getContentSerializerback to summary
public JsonSerializer<?> getContentSerializer()

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

Doc from 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. Note that for dynamic types this may return null; if so, caller has to instead use getContentType() and com.fasterxml.jackson.databind.SerializerProvider#findContentValueSerializer.

Annotations
@Override
getContentTypeback to summary
public JavaType getContentType()

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

Doc from com.fasterxml.jackson.databind.ser.ContainerSerializer.getContentType.

Accessor for finding declared (static) element type for type this serializer is used for.

Annotations
@Override
getSchemaback to summary
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException

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

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

Doc from com.fasterxml.jackson.databind.ser.std.StdSerializer.getSchema.

Deprecated

Since 2.15

Default implementation simply claims type is "string"; usually overriden by custom serializers.

Parameters
provider:SerializerProvider

Doc from com.fasterxml.jackson.databind.jsonschema.SchemaAware.getSchema.

The serializer provider.

typeHint:Type

Doc from com.fasterxml.jackson.databind.jsonschema.SchemaAware.getSchema.

A hint about the type.

Returns:JsonNode

Doc from com.fasterxml.jackson.databind.jsonschema.SchemaAware.getSchema.

Json-schema for this serializer.

Annotations
@Deprecated
@Override
serializeback to summary
public void serialize(T value, JsonGenerator gen, SerializerProvider provider) throws IOException

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

Doc from com.fasterxml.jackson.databind.JsonSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Parameters
value:T

Value to serialize; can not be null.

gen:JsonGenerator

Generator used to output resulting Json content

provider:SerializerProvider

Provider that can be used to get serializers for serializing Objects value contains, if any.

Annotations
@Override
serializeContentsback to summary
protected abstract void serializeContents(T value, JsonGenerator gen, SerializerProvider provider) throws IOException
serializeWithTypeback to summary
public void serializeWithType(T value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException

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

Doc from 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.

Default implementation will throw UnsupportedOperationException to indicate that proper type handling needs to be implemented.

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.
Parameters
value:T

Value to serialize; can not be null.

g:JsonGenerator

Generator used to output resulting Json content

provider:SerializerProvider

Provider that can be used to get serializers for serializing Objects value contains, if any.

typeSer:TypeSerializer

Type serializer to use for including type information

Annotations
@Override
withResolvedback to summary
public final AsArraySerializerBase<T> withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer)

Deprecated

since 2.6: use the overloaded method that takes 'unwrapSingle'

Annotations
@Deprecated
withResolvedback to summary
public abstract AsArraySerializerBase<T> withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)

References Deprecated

AsArraySerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Since
2.6