Class FloatSerializer
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable,com.fasterxml.jackson.databind.jsonschema.SchemaAware,Serializable
A custom serializer for
Float values, extending StdSerializer.
This serializer handles special floating-point values, converting them into their
textual representations in JSON.
Special handling is provided for:
Float.POSITIVE_INFINITYandFloat.MAX_VALUE: Serialized as"Infinity".Float.NEGATIVE_INFINITYand-Float.MAX_VALUE: Serialized as"-Infinity".Float.NaN: Serialized as"NaN".- All other valid
Floatvalues: Serialized as 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
-
FloatSerializer
public FloatSerializer()Default constructor. Initializes the serializer forFloattype.
-
-
Method Details
-
serialize
public void serialize(Float value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider provider) throws IOException Serializes aFloatvalue into JSON.Converts special floating-point values into their respective textual representations:
"Infinity"forFloat.POSITIVE_INFINITYandFloat.MAX_VALUE."-Infinity"forFloat.NEGATIVE_INFINITYand-Float.MAX_VALUE."NaN"forFloat.NaN.- Other numeric values are serialized as standard numbers.
- Specified by:
serializein classcom.fasterxml.jackson.databind.ser.std.StdSerializer<Float>- Parameters:
value- theFloatvalue to serialize.gen- theJsonGeneratorused to write JSON content.provider- theSerializerProviderfor accessing serialization configuration.- Throws:
IOException- if an I/O error occurs during serialization.
-