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
Base class for Json serialization implementation.
This class provides basic functionality for serializing and deserializing objects to and from JSON format.
-
Constructor Summary
ConstructorsConstructorDescriptionBaseJsonSerializer
(Class<T> clazz) Constructor for BaseJsonSerializer class. -
Method Summary
-
Constructor Details
-
BaseJsonSerializer
Constructor for BaseJsonSerializer class.- Parameters:
clazz
- the class of the object to serialize and deserialize
-
-
Method Details
-
serialize
Serialize an object to a JSON String.- Specified by:
serialize
in interfaceJsonSerializer<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
Deserialize a JSON String to an object.- Specified by:
deserialize
in interfaceJsonSerializer<T>
- Parameters:
object
- the JSON String to deserialize- Returns:
- the deserialized object
- Throws:
IOException
- if an error occurs during deserialization
-