Class CustomizedObjectSerializer<T>

java.lang.Object
io.micronaut.serde.support.serializers.CustomizedObjectSerializer<T>
Type Parameters:
T - The type to serialize
All Implemented Interfaces:
Serializer<T>

@Internal public class CustomizedObjectSerializer<T> extends Object implements Serializer<T>
Fallback Serializer for general Object values. For deserialization, deserializes to standard types like Number, String, Boolean, Map and List.

This class is used in multiple scenarios:

  • When the user has an Object property in a serializable bean.
  • When the user explicitly calls JsonMapper.writeValue(java.io.OutputStream, java.lang.Object)(gen, Object .class)
  • Constructor Details

    • CustomizedObjectSerializer

      public CustomizedObjectSerializer(io.micronaut.serde.support.serializers.SerBean<Object> serBean)
  • Method Details

    • serialize

      public final void serialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) throws IOException
      Description copied from interface: Serializer
      Serializes the given value using the passed Encoder.
      Specified by:
      serialize in interface Serializer<T>
      Parameters:
      encoder - The encoder to use
      context - The encoder context, never null
      type - Models the generic type of the value
      value - The value, can be null
      Throws:
      IOException - If an error occurs during serialization
    • getWriteProperties

      @NonNull protected @NonNull List<io.micronaut.serde.support.serializers.SerBean.SerProperty<Object,Object>> getWriteProperties(io.micronaut.serde.support.serializers.SerBean<Object> serBean)
      Obtains the write properties for this serializer.
      Parameters:
      serBean - The serialization bean.
      Returns:
      The write properties, never null