Interface SerDes

All Known Implementing Classes:
JacksonSerDes, NoopSerDes

public interface SerDes
Interface for serialization and deserialization of objects.

Implementations must support both simple types via Class and complex generic types via TypeToken.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    deserialize(String data, TypeToken<T> typeToken)
    Deserializes a JSON string to an object of the specified generic type.
    Serializes an object to a JSON string.
  • Method Details

    • serialize

      String serialize(Object value)
      Serializes an object to a JSON string.
      Parameters:
      value - the object to serialize
      Returns:
      the JSON string representation, or null if value is null
    • deserialize

      <T> T deserialize(String data, TypeToken<T> typeToken)
      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>>() {});
       
      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