Class JsonSerializer

java.lang.Object
com.algolia.internal.JsonSerializer

public final class JsonSerializer extends Object
Utility class for JSON serialization and deserialization using Jackson. It provides functionality to convert Java objects to their JSON representation and vice versa.
  • Method Details

    • builder

      public static JsonSerializer.Builder builder()
    • serialize

      public void serialize(OutputStream stream, @Nonnull Object object)
      Serializes a Java object into its JSON representation.
      Parameters:
      stream - output steam.
      object - The Java object to serialize.
    • deserialize

      public <T> T deserialize(InputStream stream, com.fasterxml.jackson.databind.JavaType returnType)
      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.