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

public Class BeanAsArraySerializer

extends BeanSerializerBase
Class Inheritance
Imports
java.io.IOException, java.util.Set, com.fasterxml.jackson.core.JsonGenerator, .JsonToken, com.fasterxml.jackson.core.type.WritableTypeId, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.ser.BeanPropertyWriter, com.fasterxml.jackson.databind.ser.std.BeanSerializerBase, com.fasterxml.jackson.databind.util.NameTransformer

References Deprecated

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

See corresponding docs for further information.

Specialized POJO serializer that differs from com.fasterxml.jackson.databind.ser.BeanSerializer in that instead of producing a JSON Object it will output a JSON Array, omitting field names, and serializing values in specified serialization order. This behavior is usually triggered by using annotation com.fasterxml.jackson.annotation.JsonFormat or its equivalents.

This serializer can be used for "simple" instances; and will NOT be used if one of following is true:

Note that it is theoretically possible that last 2 issues could be addressed (by reserving room in array, for example); and if so, support improved.

In cases where array-based output is not feasible, this serializer can instead delegate to the original Object-based serializer; this is why a reference is retained to the original serializer.

Since
2.1

Field Summary

Modifier and TypeField and Description
protected final BeanSerializerBase
_defaultSerializer

References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.
Serializer that would produce JSON Object version; used in cases where array output cannot be used.
private static final long
Inherited from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase:
_anyGetterWriter_beanType_filteredProps_objectIdWriter_propertyFilterId_props_serializationShape_typeIdNAME_FOR_OBJECT_REFNO_PROPS

Constructor Summary

AccessConstructor and Description
public
BeanAsArraySerializer(BeanSerializerBase src)
References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

protected
BeanAsArraySerializer(BeanSerializerBase src, Set<String> toIgnore)
References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

protected
BeanAsArraySerializer(BeanSerializerBase src, Set<String> toIgnore, Set<String> toInclude)
References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

protected
BeanAsArraySerializer(BeanSerializerBase src, ObjectIdWriter oiw, Object filterId)
References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
protected BeanSerializerBase
asArraySerializer()

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.asArraySerializer.

References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

Mutant factory for creating a variant that output POJO as a JSON Array.

private boolean
public boolean
isUnwrappingSerializer()

Overrides com.fasterxml.jackson.databind.JsonSerializer.isUnwrappingSerializer.

Accessor for checking whether this serializer is an "unwrapping" serializer; this is necessary to know since it may also require caller to suppress writing of the leading property name.

public final void
serialize(Object
Value to serialize; can not be null.
bean
,
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.BeanSerializerBase.serialize.

Main serialization method that will delegate actual output to configured BeanPropertyWriter instances.

protected final void
public void
serializeWithType(Object
Value to serialize; can not be null.
bean
,
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.ser.std.BeanSerializerBase.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 String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public JsonSerializer<Object>
unwrappingSerializer(NameTransformer
Name transformation to use to convert between names of unwrapper properties
transformer
)

Overrides com.fasterxml.jackson.databind.JsonSerializer.unwrappingSerializer.

Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output).

protected BeanAsArraySerializer
withByNameInclusion(Set<String> toIgnore, Set<String> toInclude)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withByNameInclusion.

References Deprecated BeanAsArraySerializer is deprecated or references (maybe indirectly) at least one deprecated element.

Mutant factory used for creating a new instance with additional set of properties to ignore or include (from properties this instance otherwise has)

public BeanSerializerBase
withFilterId(Object filterId)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withFilterId.

References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

Mutant factory used for creating a new instance with different filter id (used with JsonFilter annotation)

public BeanSerializerBase
withObjectIdWriter(ObjectIdWriter objectIdWriter)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withObjectIdWriter.

References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

Mutant factory used for creating a new instance with different ObjectIdWriter.

protected BeanSerializerBase
withProperties(BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withProperties.

References Deprecated BeanSerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

Mutant factory used for creating a new instance with modified set of properties.

Inherited from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase:
_customTypeId_serializeObjectId_serializeWithObjectId_serializeWithObjectId_typeIdDefacceptJsonFormatVisitorcreateContextualfindConvertingSerializergetSchemapropertiesresolveserializeFieldsserializeFieldsFilteredusesObjectIdwithIgnoralswithIgnorals

Field Detail

_defaultSerializerback to summary
protected final BeanSerializerBase _defaultSerializer

References Deprecated

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

See corresponding docs for further information.

Serializer that would produce JSON Object version; used in cases where array output cannot be used.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.ser.std.StdSerializer.serialVersionUID.

Constructor Detail

BeanAsArraySerializerback to summary
public BeanAsArraySerializer(BeanSerializerBase src)

References Deprecated

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

See corresponding docs for further information.

BeanAsArraySerializerback to summary
protected BeanAsArraySerializer(BeanSerializerBase src, Set<String> toIgnore)

References Deprecated

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

See corresponding docs for further information.

BeanAsArraySerializerback to summary
protected BeanAsArraySerializer(BeanSerializerBase src, Set<String> toIgnore, Set<String> toInclude)

References Deprecated

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

See corresponding docs for further information.

BeanAsArraySerializerback to summary
protected BeanAsArraySerializer(BeanSerializerBase src, ObjectIdWriter oiw, Object filterId)

References Deprecated

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

See corresponding docs for further information.

Method Detail

asArraySerializerback to summary
protected BeanSerializerBase asArraySerializer()

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.asArraySerializer.

Doc from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.asArraySerializer.

References Deprecated

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

See corresponding docs for further information.

Mutant factory for creating a variant that output POJO as a JSON Array. Implementations may ignore this request if output as array is not possible (either at all, or reliably).

Annotations
@Override
hasSingleElementback to summary
private boolean hasSingleElement(SerializerProvider provider)
isUnwrappingSerializerback to summary
public boolean isUnwrappingSerializer()

Overrides com.fasterxml.jackson.databind.JsonSerializer.isUnwrappingSerializer.

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

Accessor for checking whether this serializer is an "unwrapping" serializer; this is necessary to know since it may also require caller to suppress writing of the leading property name.

Annotations
@Override
serializeback to summary
public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException

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

Main serialization method that will delegate actual output to configured BeanPropertyWriter instances.

Parameters
bean:Object

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

Value to serialize; can not be null.

gen:JsonGenerator

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

Generator used to output resulting Json content

provider:SerializerProvider

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

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

Annotations
@Override
serializeAsArrayback to summary
protected final void serializeAsArray(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException
serializeWithTypeback to summary
public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException

Overrides com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.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
bean:Object

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.

typeSer:TypeSerializer

Type serializer to use for including type information

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
unwrappingSerializerback to summary
public JsonSerializer<Object> unwrappingSerializer(NameTransformer transformer)

Overrides com.fasterxml.jackson.databind.JsonSerializer.unwrappingSerializer.

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

Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output). If no unwrapped serializer can be constructed, will simply return serializer as-is.

Default implementation just returns serializer as-is, indicating that no unwrapped variant exists

Parameters
transformer:NameTransformer

Name transformation to use to convert between names of unwrapper properties

Annotations
@Override
withByNameInclusionback to summary
protected BeanAsArraySerializer withByNameInclusion(Set<String> toIgnore, Set<String> toInclude)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withByNameInclusion.

Doc from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withByNameInclusion.

References Deprecated

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

See corresponding docs for further information.

Mutant factory used for creating a new instance with additional set of properties to ignore or include (from properties this instance otherwise has)

Annotations
@Override
withFilterIdback to summary
public BeanSerializerBase withFilterId(Object filterId)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withFilterId.

Doc from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withFilterId.

References Deprecated

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

See corresponding docs for further information.

Mutant factory used for creating a new instance with different filter id (used with JsonFilter annotation)

Annotations
@Override
withObjectIdWriterback to summary
public BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withObjectIdWriter.

Doc from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withObjectIdWriter.

References Deprecated

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

See corresponding docs for further information.

Mutant factory used for creating a new instance with different ObjectIdWriter.

Annotations
@Override
withPropertiesback to summary
protected BeanSerializerBase withProperties(BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Implements abstract com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withProperties.

Doc from com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.withProperties.

References Deprecated

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

See corresponding docs for further information.

Mutant factory used for creating a new instance with modified set of properties.

Note

in 2.11.x, need to keep non-abstract for slightly better compatibility (XML module extends)

Annotations
@Override