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

public final Class BooleanSerializer

extends StdScalarSerializer<Object>
implements ContextualSerializer
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.ser.ContextualSerializer
Annotations
@JacksonStdImpl
Imports
java.io.IOException, java.lang.reflect.Type, com.fasterxml.jackson.annotation.JsonFormat, com.fasterxml.jackson.core.JsonGenerator, .JsonParser.NumberType, com.fasterxml.jackson.databind.BeanProperty, .JavaType, .JsonMappingException, .JsonNode, .JsonSerializer, .SerializerProvider, com.fasterxml.jackson.databind.annotation.JacksonStdImpl, com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.ser.ContextualSerializer

References Deprecated

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

See corresponding docs for further information.

Serializer used for primitive boolean, as well as java.util.Boolean wrapper type.

Since this is one of "natural" (aka "native") types, no type information is ever included on serialization (unlike for most other scalar types)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
BooleanSerializer.AsNumber

References Deprecated StdScalarSerializer is deprecated or references (maybe indirectly) at least one deprecated element.
Alternate implementation that is used when values are to be serialized as numbers 0 (false) or 1 (true).

Field Summary

Modifier and TypeField and Description
protected final boolean
_forPrimitive

Whether type serialized is primitive (boolean) or wrapper (java.lang.Boolean); if true, former, if false, latter.

private static final long

Constructor Summary

AccessConstructor and Description
public
BooleanSerializer(boolean forPrimitive)

Method Summary

Modifier and TypeMethod and Description
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.

Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property.

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

Overrides com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.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(Object
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
)

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 final void
serializeWithType(Object
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.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix.

Field Detail

_forPrimitiveback to summary
protected final boolean _forPrimitive

Whether type serialized is primitive (boolean) or wrapper (java.lang.Boolean); if true, former, if false, latter.

serialVersionUIDback to summary
private static final long serialVersionUID

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

Constructor Detail

BooleanSerializerback to summary
public BooleanSerializer(boolean forPrimitive)

Method Detail

acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException

Overrides com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.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.

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

Parameters
serializers:SerializerProvider

Serializer provider to use for accessing config, other serializers

property: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)

Returns:JsonSerializer<?>

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

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

Overrides com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.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(Object value, JsonGenerator g, 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:Object

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.

Annotations
@Override
serializeWithTypeback to summary
public final void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException

Overrides com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Doc from com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix. This should work for most cases; some sub-classes may want to change this behavior.

Parameters
value:Object

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

Value to serialize; can not be null.

g:JsonGenerator

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

Generator used to output resulting Json content

provider:SerializerProvider

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

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

typeSer:TypeSerializer

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

Type serializer to use for including type information

Annotations
@Override
com.fasterxml.jackson.databind.ser.std back to summary

pack-priv final Class BooleanSerializer.AsNumber

extends StdScalarSerializer<Object>
implements ContextualSerializer
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.ser.ContextualSerializer

References Deprecated

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

See corresponding docs for further information.

Alternate implementation that is used when values are to be serialized as numbers 0 (false) or 1 (true).
Since
2.9

Field Summary

Modifier and TypeField and Description
protected final boolean
_forPrimitive

Whether type serialized is primitive (boolean) or wrapper (java.lang.Boolean); if true, former, if false, latter.

private static final long

Constructor Summary

AccessConstructor and Description
public
AsNumber(boolean forPrimitive)

Method Summary

Modifier and TypeMethod and Description
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.

Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property.

public void
serialize(Object
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
)

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 final void
serializeWithType(Object
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.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix.

Inherited from com.fasterxml.jackson.databind.ser.std.StdScalarSerializer:
getSchema

Field Detail

_forPrimitiveback to summary
protected final boolean _forPrimitive

Whether type serialized is primitive (boolean) or wrapper (java.lang.Boolean); if true, former, if false, latter.

serialVersionUIDback to summary
private static final long serialVersionUID

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

Constructor Detail

AsNumberback to summary
public AsNumber(boolean forPrimitive)

Method Detail

acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException

Overrides com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.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.

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

Parameters
serializers:SerializerProvider

Serializer provider to use for accessing config, other serializers

property: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)

Returns:JsonSerializer<?>

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

Annotations
@Override
serializeback to summary
public void serialize(Object value, JsonGenerator g, 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:Object

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.

Annotations
@Override
serializeWithTypeback to summary
public final void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException

Overrides com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Doc from com.fasterxml.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix. This should work for most cases; some sub-classes may want to change this behavior.

Parameters
value:Object

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

Value to serialize; can not be null.

g:JsonGenerator

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

Generator used to output resulting Json content

provider:SerializerProvider

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

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

typeSer:TypeSerializer

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

Type serializer to use for including type information

Annotations
@Override