@Test
public void writer() {

    String str = "{\"foo\":42}";
    JSONObject obj = new JSONObject(str);
    StringWriter sw = new StringWriter();
    obj.write(sw);
    assertEquals(str, sw.toString());
}