Update for JSONArray.putAll methods

* Adds a copy constructor for JSONArray
* Updates the JSONArray.addAll(Object) method to be more lenient
* Adds support for JSONArray.putAll of generic Iterables
* Adds support for JSONArray.putAll of another JSONArray
This commit is contained in:
John J. Aylward
2020-07-27 11:39:55 -04:00
parent 6351fa63aa
commit f37c2d67c5
3 changed files with 158 additions and 5 deletions

View File

@@ -3201,4 +3201,11 @@ public class JSONObjectTest {
fail("Expected an exception");
}
@Test
public void testIssue548ObjectWithEmptyJsonArray() {
JSONObject jsonObject = new JSONObject("{\"empty_json_array\": []}");
assertTrue("missing expected key 'empty_json_array'", jsonObject.has("empty_json_array"));
assertNotNull("'empty_json_array' should be an array", jsonObject.getJSONArray("empty_json_array"));
assertEquals("'empty_json_array' should have a length of 0", 0, jsonObject.getJSONArray("empty_json_array").length());
}
}