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