JacksonObjectMapper { public String prettyPrint(Object object) throws IOException { objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS); try { return objectMapper .writerWithDefaultPrettyPrinter().writeValueAsString(object); }finally { objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); } } JacksonObjectMapper(ObjectMapper objectMapper); T fromJson(byte[] bytes, Class<T> type); T fromJson(byte[] bytes, Class<T> type, Class<?> view); Map<String, String> fromJsonToMap(byte[] bytes); byte[] toJson(Object object); byte[] toJson(Object object, Class<?> serializationView); byte[] toJson(Map<String, String> map); byte[] toPrettyJson(Object object, Class<?> serializationView); String prettyPrint(Object object); String prettyPrint(String json); void checkValidJson(byte[] bytes); T assign(T target, byte[] source);  }
@Test public void should_format_json_when_using_pretty_print_on_object() throws Exception { SimpleObject object = new SimpleObject("id", "Vincent", 1); assertThat(objectMapper.prettyPrint(object)).isEqualTo("{" + System.lineSeparator() + " \"id\" : \"id\"," + System.lineSeparator() + " \"name\" : \"Vincent\"," + System.lineSeparator() + " \"number\" : 1," + System.lineSeparator() + " \"another\" : null" + System.lineSeparator() + "}"); }
@Test public void should_format_json_when_using_pretty_print_on_json() throws Exception { assertThat(objectMapper.prettyPrint("{\"foo\":\"bar\"}")).isEqualTo("{" + System.lineSeparator() + " \"foo\" : \"bar\"" + System.lineSeparator() + "}"); }