mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
Merge pull request #907 from hexetia/fix-901
Fix a bug when calling JSONArray.addAll() with Collection as Object
This commit is contained in:
commit
2ee5bf13f4
@ -1939,7 +1939,7 @@ public class JSONArray implements Iterable<Object> {
|
|||||||
// JSONArray
|
// JSONArray
|
||||||
this.myArrayList.addAll(((JSONArray)array).myArrayList);
|
this.myArrayList.addAll(((JSONArray)array).myArrayList);
|
||||||
} else if (array instanceof Collection) {
|
} else if (array instanceof Collection) {
|
||||||
this.addAll((Collection<?>)array, wrap, recursionDepth);
|
this.addAll((Collection<?>)array, wrap, recursionDepth, jsonParserConfiguration);
|
||||||
} else if (array instanceof Iterable) {
|
} else if (array instanceof Iterable) {
|
||||||
this.addAll((Iterable<?>)array, wrap);
|
this.addAll((Iterable<?>)array, wrap);
|
||||||
} else {
|
} else {
|
||||||
|
@ -259,6 +259,11 @@ public class JSONArrayTest {
|
|||||||
jsonArray.length(),
|
jsonArray.length(),
|
||||||
len);
|
len);
|
||||||
|
|
||||||
|
// collection as object
|
||||||
|
@SuppressWarnings("RedundantCast")
|
||||||
|
Object myListAsObject = (Object) myList;
|
||||||
|
jsonArray.putAll(myListAsObject);
|
||||||
|
|
||||||
for (int i = 0; i < myList.size(); i++) {
|
for (int i = 0; i < myList.size(); i++) {
|
||||||
assertEquals("collection elements should be equal",
|
assertEquals("collection elements should be equal",
|
||||||
myList.get(i),
|
myList.get(i),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user