@Test
public void toJSONArray() {

    JSONObject o = new JSONObject(of("foo","bar","baz",42));
    assertNull(o.toJSONArray(new JSONArray()));
    assertEquals(new JSONArray(asList("bar", 42)),
            o.toJSONArray(new JSONArray(asList("foo", "baz"))));
    assertEquals(new JSONArray(asList(null, null)),
            new JSONObject().toJSONArray(new JSONArray(asList("foo", "baz"))));
}