java.lang.Object
tools.jackson.databind.ValueSerializer<T>
tools.jackson.databind.ser.std.StdSerializer<byte[]>
tools.jackson.databind.ser.jdk.ByteArraySerializer
- All Implemented Interfaces:
JsonFormatVisitable
Unlike other integral number array serializers, we do not just print out byte values
as numbers. Instead, we assume that it would make more sense to output content
as base64 encoded bytes (using default base64 encoding).
NOTE: since it is NOT serialized as an array, cannot use AsArraySerializer as base
NOTE: since 2.6, has been a main-level class; earlier was embedded in
JDKArraySerializers
.
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.ValueSerializer
ValueSerializer.None
-
Field Summary
Fields inherited from class tools.jackson.databind.ser.std.StdSerializer
_handledType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptJsonFormatVisitor
(JsonFormatVisitorWrapper visitor, JavaType typeHint) Default implementation specifies no format.boolean
isEmpty
(SerializationContext prov, byte[] value) Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).void
serialize
(byte[] value, JsonGenerator g, SerializationContext provider) Method that can be called to ask implementation to serialize values of type this serializer handles.void
serializeWithType
(byte[] value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) 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.Methods inherited from class tools.jackson.databind.ser.std.StdSerializer
_neitherNull, _nonEmpty, _wrapIOFailure, acceptJsonFormatVisitorForBinary, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
Methods inherited from class tools.jackson.databind.ValueSerializer
createContextual, getDelegatee, isUnwrappingSerializer, properties, replaceDelegatee, resolve, unwrappingSerializer, usesObjectId, withFilterId, withFormatOverrides, withIgnoredProperties
-
Constructor Details
-
ByteArraySerializer
public ByteArraySerializer()
-
-
Method Details
-
isEmpty
Description copied from class:ValueSerializer
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.
- Overrides:
isEmpty
in classValueSerializer<byte[]>
-
serialize
public void serialize(byte[] value, JsonGenerator g, SerializationContext provider) throws JacksonException Description copied from class:ValueSerializer
Method that can be called to ask implementation to serialize values of type this serializer handles.- Specified by:
serialize
in classStdSerializer<byte[]>
- Parameters:
value
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentprovider
- Context that can be used to get serializers for serializing Objects value contains, if any.- Throws:
JacksonException
-
serializeWithType
public void serializeWithType(byte[] value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) throws JacksonException Description copied from class:ValueSerializer
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, asSTART-ARRAY
/END-ARRAY
andSTART-OBJECT
/END-OBJECT
pairs need to be properly handled with respect to serializing of contents.- Overrides:
serializeWithType
in classValueSerializer<byte[]>
- Parameters:
value
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentctxt
- Context that can be used to get serializers for serializing Objects value contains, if any.typeSer
- Type serializer to use for including type information- Throws:
JacksonException
-
acceptJsonFormatVisitor
Description copied from class:StdSerializer
Default implementation specifies no format. This behavior is usually overriden by custom serializers.- Specified by:
acceptJsonFormatVisitor
in interfaceJsonFormatVisitable
- Overrides:
acceptJsonFormatVisitor
in classStdSerializer<byte[]>
typeHint
- Type of element (entity like property) being visited
-