Class JacksonSerDes

java.lang.Object
software.amazon.lambda.durable.serde.JacksonSerDes
All Implemented Interfaces:
SerDes

public class JacksonSerDes extends Object implements SerDes
Jackson-based implementation of SerDes.

This implementation uses Jackson's ObjectMapper for JSON serialization and deserialization, with support for both simple types via Class and complex generic types via TypeToken.

Features:

  • Java 8 time types support (Duration, Instant, LocalDateTime, etc.)
  • Dates serialized as ISO-8601 strings (not timestamps)
  • Unknown properties ignored during deserialization
  • Type cache for improved performance with generic types
  • Constructor Details

    • JacksonSerDes

      public JacksonSerDes()
  • Method Details

    • serialize

      public String serialize(Object value)
      Description copied from interface: SerDes
      Serializes an object to a JSON string.
      Specified by:
      serialize in interface SerDes
      Parameters:
      value - the object to serialize
      Returns:
      the JSON string representation, or null if value is null
    • deserialize

      public <T> T deserialize(String data, TypeToken<T> typeToken)
      Description copied from interface: SerDes
      Deserializes a JSON string to an object of the specified generic type.

      This method supports complex generic types like List<MyObject> or Map<String, MyObject> that cannot be represented by a simple Class object.

      Usage example:

      
       List<String> items = serDes.deserialize(json, new TypeToken<List<String>>() {});
       
      Specified by:
      deserialize in interface SerDes
      Type Parameters:
      T - the target type
      Parameters:
      data - the JSON string to deserialize
      typeToken - the type token capturing the generic type information
      Returns:
      the deserialized object, or null if data is null