Package com.algolia.internal
Class JsonSerializer
java.lang.Object
com.algolia.internal.JsonSerializer
Utility class for JSON serialization and deserialization using Jackson. It provides functionality
to convert Java objects to their JSON representation and vice versa.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonSerializer.Builder
builder()
<T> T
deserialize
(InputStream stream, com.fasterxml.jackson.databind.JavaType returnType) Deserializes a JSON ResponseBody into a Java object of a given type.com.fasterxml.jackson.databind.JavaType
getJavaType
(com.fasterxml.jackson.core.type.TypeReference<?> returnType) Constructs a JavaType representation for a class.com.fasterxml.jackson.databind.JavaType
getJavaType
(Class<?> returnType, Class<?> innerType) Constructs a JavaType representation for a class with parameterized types.void
serialize
(OutputStream stream, Object object) Serializes a Java object into its JSON representation.
-
Method Details
-
builder
-
serialize
Serializes a Java object into its JSON representation.- Parameters:
stream
- output steam.object
- The Java object to serialize.
-
deserialize
Deserializes a JSON ResponseBody into a Java object of a given type. -
getJavaType
public com.fasterxml.jackson.databind.JavaType getJavaType(@Nonnull Class<?> returnType, @Nonnull Class<?> innerType) Constructs a JavaType representation for a class with parameterized types.- Parameters:
returnType
- The main class type.innerType
- The parameterized type.- Returns:
- A JavaType representation of the parameterized class.
-
getJavaType
public com.fasterxml.jackson.databind.JavaType getJavaType(@Nonnull com.fasterxml.jackson.core.type.TypeReference<?> returnType) Constructs a JavaType representation for a class.- Parameters:
returnType
- The main class type.- Returns:
- A JavaType representation of the parameterized class.
-