Class BaseJsonSerializer<T>

java.lang.Object
com.example.common.json.serializer.BaseJsonSerializer<T>
Type Parameters:
T - the type of object to serialize and deserialize
All Implemented Interfaces:
JsonSerializer<T>
Direct Known Subclasses:
BodyMessageJsonSerializer

public abstract class BaseJsonSerializer<T> extends Object implements JsonSerializer<T>
Base class for Json serialization implementation. This class provides basic functionality for serializing and deserializing objects to and from JSON format.
  • Constructor Details

    • BaseJsonSerializer

      public BaseJsonSerializer(Class<T> clazz)
      Constructor for BaseJsonSerializer class.
      Parameters:
      clazz - the class of the object to serialize and deserialize
  • Method Details

    • serialize

      public String serialize(T object) throws com.fasterxml.jackson.core.JsonProcessingException
      Serialize an object to a JSON String.
      Specified by:
      serialize in interface JsonSerializer<T>
      Parameters:
      object - the object to serialize
      Returns:
      the JSON String representation of the object
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during serialization
    • deserialize

      public T deserialize(String object) throws IOException
      Deserialize a JSON String to an object.
      Specified by:
      deserialize in interface JsonSerializer<T>
      Parameters:
      object - the JSON String to deserialize
      Returns:
      the deserialized object
      Throws:
      IOException - if an error occurs during deserialization