JSONUtils { public static String toString(Object object) { try { return mapper.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 testToString() throws Exception { String result = JSONUtils.toString(data); assertThat(result, is("{\"a\":\"b\"}")); }