Class JacksonSerDes
java.lang.Object
software.amazon.lambda.durable.serde.JacksonSerDes
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
JacksonSerDes
public JacksonSerDes()
-
-
Method Details
-
serialize
Description copied from interface:SerDesSerializes an object to a JSON string. -
deserialize
Description copied from interface:SerDesDeserializes a JSON string to an object of the specified generic type.This method supports complex generic types like
List<MyObject>orMap<String, MyObject>that cannot be represented by a simpleClassobject.Usage example:
List<String> items = serDes.deserialize(json, new TypeToken<List<String>>() {});- Specified by:
deserializein interfaceSerDes- Type Parameters:
T- the target type- Parameters:
data- the JSON string to deserializetypeToken- the type token capturing the generic type information- Returns:
- the deserialized object, or null if data is null
-