JSONUtils { public static void writeValue(File file, Object value) { try { mapper.writeValue(file, value); } 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 testWriteValue() throws Exception { file = File.createTempFile("tmp", null); JSONUtils.writeValue(file, data); String result = FileUtils.readFileToString(file); assertThat(result, is("{\"a\":\"b\"}")); }