Interface RedisJsonSerializer

All Superinterfaces:
RedisSerializer<Object>
All Known Implementing Classes:
GenericJackson2JsonRedisSerializer, GenericJacksonJsonRedisSerializer

public interface RedisJsonSerializer extends RedisSerializer<Object>
RedisSerializer extension for converting Objects to and from their JSON byte[] representation.

A JSON serializer primarily adds convenient methods for deserializing JSON into typed objects.

Since:
4.2
Author:
Yordan Tsintsov, Mark Paluch
  • Method Details

    • deserialize

      default <T> @Nullable T deserialize(byte[] source, ParameterizedTypeReference<T> typeRef) throws SerializationException
      Deserialize the given source into an instance of the type described by a ParameterizedTypeReference. Use this variant for generic types such as List<Person> that cannot be expressed as a Class.
      Type Parameters:
      T - the target type.
      Parameters:
      source - the JSON representation to read.
      typeRef - reference describing the target type.
      Returns:
      the deserialized object, or null if source is empty or represents JSON null.
      Throws:
      SerializationException - if the JSON cannot be deserialized.
    • deserialize

      @Nullable Object deserialize(byte[] source, ResolvableType type) throws SerializationException
      Deserialize the given source into an instance of the type described by ResolvableType. Use this variant for generic types such as List<Person> that cannot be expressed as a Class.
      Parameters:
      source - the JSON representation to read.
      type - reference describing the target type.
      Returns:
      the deserialized object, or null if source is empty or represents JSON null.
      Throws:
      SerializationException - if the JSON cannot be deserialized.