Class KafkaJsonDecoder<T>

java.lang.Object
io.confluent.kafka.serializers.KafkaJsonDeserializer<T>
io.confluent.kafka.serializers.KafkaJsonDecoder<T>
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.serialization.Deserializer<T>, org.apache.kafka.tools.api.Decoder<T>

public class KafkaJsonDecoder<T> extends KafkaJsonDeserializer<T> implements org.apache.kafka.tools.api.Decoder<T>
Decode JSON data to an Object.
  • Constructor Details

    • KafkaJsonDecoder

      public KafkaJsonDecoder(kafka.utils.VerifiableProperties props)
      This constructor is needed by Kafka. When used directly or through reflection, the type will default to Object since there is no way to infer a generic type. In particular, it is an error to do the following:
      
         // WARNING: DON'T DO THIS
         KafkaJsonDecoder<String> decoder = new KafkaJsonDecoder<String>(props);
         
       

      Instead you must use KafkaJsonDecoder(VerifiableProperties, Class) with the expected type.

      Parameters:
      props - The decoder configuration
    • KafkaJsonDecoder

      public KafkaJsonDecoder(kafka.utils.VerifiableProperties props, Class<T> type)
      Create a new decoder using the expected type to decode to
      Parameters:
      props - The decoder configuration
      type - The type of objects constructed
  • Method Details

    • fromBytes

      public T fromBytes(byte[] bytes)
      Specified by:
      fromBytes in interface org.apache.kafka.tools.api.Decoder<T>