JacksonJsonObjectMarshaller implements JsonObjectMarshaller<T> { @Override public String marshal(T item) { try { return objectMapper.writeValueAsString(item); } catch (JsonProcessingException e) { throw new ItemStreamException("Unable to marshal object " + item + " to Json", e); } }  void setObjectMapper(ObjectMapper objectMapper); @Override String marshal(T item);  }
@Test public void testJsonMarshalling() { JacksonJsonObjectMarshaller<Foo> jsonObjectMarshaller = new JacksonJsonObjectMarshaller<>(); String foo = jsonObjectMarshaller.marshal(new Foo(1, "foo")); Assert.assertEquals("{\"id\":1,\"name\":\"foo\"}", foo); }