Class DoubleSerializer
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable,com.fasterxml.jackson.databind.jsonschema.SchemaAware,Serializable
A custom serializer for
Double values, extending StdSerializer.
This serializer handles special cases of floating-point numbers, converting them
to their textual representations in JSON.
Special handling is provided for:
Double.POSITIVE_INFINITYandDouble.MAX_VALUE: serialized as "Infinity".Double.NEGATIVE_INFINITYand-Double.MAX_VALUE: serialized as "-Infinity".Double.NaN: serialized as "NaN".- All other
Doublevalues: serialized as standard numeric values.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer
com.fasterxml.jackson.databind.JsonSerializer.None -
Field Summary
Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
_handledType -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
_neitherNull, _nonEmpty, acceptJsonFormatVisitor, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrowMethods inherited from class com.fasterxml.jackson.databind.JsonSerializer
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties
-
Constructor Details
-
DoubleSerializer
public DoubleSerializer()Default constructor. Initializes the serializer forDoubletype.
-
-
Method Details
-
serialize
public void serialize(Double value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider provider) throws IOException Serializes aDoublevalue into JSON.Converts special floating-point values into their respective textual representations:
- "Infinity" for
Double.POSITIVE_INFINITYandDouble.MAX_VALUE. - "-Infinity" for
Double.NEGATIVE_INFINITYand-Double.MAX_VALUE. - "NaN" for
Double.NaN. - Other numeric values are serialized as numbers.
- Specified by:
serializein classcom.fasterxml.jackson.databind.ser.std.StdSerializer<Double>- Parameters:
value- theDoublevalue to serialize.gen- theJsonGeneratorused to write JSON content.provider- theSerializerProviderfor accessing serialization configuration.- Throws:
IOException- if an I/O error occurs during serialization.
- "Infinity" for
-