JSONUtils { public static String toStringWithIndent(Object object) { try { return indentMapper.writeValueAsString(object); } catch (IOException e) { throw new JSONException(e); } } private  JSONUtils(); static T readValue(File file, Class<T> clss); static T readValue(File file, TypeReference<T> reference); static T readValue(InputStream in, TypeReference<T> reference); static T readValue(InputStream in, Class<T> clss); static String toString(Object object); static void writeValue(File file, Object value); static String toStringWithIndent(Object object); static void writeValueWithIndent(File file, Object value);  }
@Test public void testToStringWithIndent() throws Exception { String result = JSONUtils.toStringWithIndent(data); assertThat(result.split(System.lineSeparator()), is(new String[] { "{", " \"a\" : \"b\"", "}" })); }