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

public Class NumberSerializer

extends StdScalarSerializer<Number>
implements ContextualSerializer
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.databind.ser.ContextualSerializer
Annotations
@JacksonStdImpl
@SuppressWarnings:serial
Imports
java.io.IOException, java.lang.reflect.Type, java.math.BigDecimal, .BigInteger, com.fasterxml.jackson.annotation.JsonFormat, com.fasterxml.jackson.core.JsonGenerator, .JsonParser, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.annotation.JacksonStdImpl, com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.ser.ContextualSerializer

Deprecated

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

As a fallback, we may need to use this serializer for other types of Numbers: both custom types and "big" numbers like BigInteger and BigDecimal.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
NumberSerializer.BigDecimalAsStringSerializer

Deprecated as a consequence of ToStringSerializerBase being deprecated.

Field Summary

Modifier and TypeField and Description
protected final boolean
public static final NumberSerializer
instance

Static instance that is only to be used for java.lang.Number.

protected static final int
MAX_BIG_DECIMAL_SCALE

Copied from `jackson-core` class `GeneratorBase`

Constructor Summary

AccessConstructor and Description
public
NumberSerializer(Class<? extends Number> rawType)

Method Summary

Modifier and TypeMethod and Description
public void
public static JsonSerializer<?>
public JsonSerializer<?>
createContextual(SerializerProvider
Serializer provider to use for accessing config, other serializers
prov
,
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(Number
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.
Inherited from com.fasterxml.jackson.databind.ser.std.StdScalarSerializer:
serializeWithType

Field Detail

_isIntback to summary
protected final boolean _isInt
instanceback to summary
public static final NumberSerializer instance

Deprecated

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

Static instance that is only to be used for java.lang.Number.

MAX_BIG_DECIMAL_SCALEback to summary
protected static final int MAX_BIG_DECIMAL_SCALE

Copied from `jackson-core` class `GeneratorBase`

Constructor Detail

NumberSerializerback to summary
public NumberSerializer(Class<? extends Number> rawType)
Since
2.5

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
bigDecimalAsStringSerializerback to summary
public static JsonSerializer<?> bigDecimalAsStringSerializer()
Since
2.10
createContextualback to summary
public JsonSerializer<?> createContextual(SerializerProvider prov, 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
prov: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(Number 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:Number

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
com.fasterxml.jackson.databind.ser.std back to summary

pack-priv final Class NumberSerializer.BigDecimalAsStringSerializer

extends ToStringSerializerBase
Class Inheritance

Deprecated

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

Field Summary

Modifier and TypeField and Description
pack-priv static final NumberSerializer.BigDecimalAsStringSerializer
BD_INSTANCE

Deprecated as a consequence of NumberSerializer.BigDecimalAsStringSerializer being deprecated.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
public boolean
isEmpty(SerializerProvider prov, Object value)

Overrides com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase.isEmpty.

Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).
public void
serialize(Object
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
)

Overrides com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.
public String
Inherited from com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase:
acceptJsonFormatVisitorgetSchemaserializeWithType

Field Detail

BD_INSTANCEback to summary
pack-priv static final NumberSerializer.BigDecimalAsStringSerializer BD_INSTANCE

Deprecated

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

Constructor Detail

BigDecimalAsStringSerializerback to summary
public BigDecimalAsStringSerializer()

Method Detail

_verifyBigDecimalRangeback to summary
protected boolean _verifyBigDecimalRange(JsonGenerator gen, BigDecimal value) throws IOException
isEmptyback to summary
public boolean isEmpty(SerializerProvider prov, Object value)

Overrides com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase.isEmpty.

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

Default implementation will consider only null values to be empty.

Note

replaces isEmpty(Object), which was deprecated in 2.5

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

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

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
valueToStringback to summary
public String valueToString(Object value)

Implements abstract com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase.valueToString.

Annotations
@Override