JsonRecordMarshaller implements RecordMarshaller<P, String> { @Override public JsonRecord processRecord(final Record<P> record) { String payload = jsonb.toJson(record.getPayload()); return new JsonRecord(record.getHeader(), payload); } JsonRecordMarshaller();  JsonRecordMarshaller(final Jsonb jsonb); @Override JsonRecord processRecord(final Record<P> record);  }
@Test public void marshal() { Tweet tweet = new Tweet(1, "foo", "hi"); Record<Tweet> record = new GenericRecord<>(header, tweet); String expected = "{\"id\":1,\"message\":\"hi\",\"user\":\"foo\"}"; JsonRecord actual = marshaller.processRecord(record); assertThat(actual.getHeader()).isEqualTo(header); assertThat(actual.getPayload()).isEqualTo(expected); }