@Test public void serialize() throws Exception { Map<String, Object> message = new HashMap<>(); message.put("foo", "bar"); message.put("baz", 354.99); byte[] bytes = serializer.serialize("foo", message); Object deserialized = this.objectMapper.readValue(bytes, Object.class); assertEquals(message, deserialized); }
@Override public byte[] serialize(String topic, T data) { if (data == null) { return null; } try { return objectMapper.writeValueAsBytes(data); } catch (Exception e) { throw new SerializationException("Error serializing JSON message", e); } }
KafkaJsonSerializer implements Serializer<T> { @Override public byte[] serialize(String topic, T data) { if (data == null) { return null; } try { return objectMapper.writeValueAsBytes(data); } catch (Exception e) { throw new SerializationException("Error serializing JSON message", e); } } }
KafkaJsonSerializer implements Serializer<T> { @Override public byte[] serialize(String topic, T data) { if (data == null) { return null; } try { return objectMapper.writeValueAsBytes(data); } catch (Exception e) { throw new SerializationException("Error serializing JSON message", e); } } KafkaJsonSerializer(); }
KafkaJsonSerializer implements Serializer<T> { @Override public byte[] serialize(String topic, T data) { if (data == null) { return null; } try { return objectMapper.writeValueAsBytes(data); } catch (Exception e) { throw new SerializationException("Error serializing JSON message", e); } } KafkaJsonSerializer(); @Override void configure(Map<String, ?> config, boolean isKey); @Override byte[] serialize(String topic, T data); @Override void close(); }
KafkaJsonSerializer implements Serializer<T> { @Override public byte[] serialize(String topic, T data) { if (data == null) { return null; } try { return objectMapper.writeValueAsBytes(data); } catch (Exception e) { throw new SerializationException("Error serializing JSON message", e); } } KafkaJsonSerializer(); @Override void configure(Map<String, ?> config, boolean isKey); @Override byte[] serialize(String topic, T data); @Override void close();  }