Commit f35194b
John J. Aylward
Updates the
When called from the constructor, the individual items in the
collection/array are wrapped as done originally before the `putAll`
methods were added.
However this commit changes how `putAll` works. The items are no longer
wrapped in order to keep consistency with the other `put` methods.
However this can lead to inconsistencies with expectations. For example
code like this will create a mixed JSONArray, some items wrapped, others
not:
```java
SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray(myArr); // these will be wrapped
// these will not be wrapped
jArr.putAll(new SomeBean[]{ new SomeBean(3), new SomeBean(4) });
```
For consistency, it would be recommended that the above code is changed
to look like 1 of 2 ways.
Option 1:
```Java
SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray();
jArr.putAll(myArr); // will not be wrapped
// these will not be wrapped
jArr.putAll(new SomeBean[]{ new SomeBean(3), new SomeBean(4) });
// our jArr is now consistent.
```
Option 2:
```Java
SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray(myArr); // these will be wrapped
// these will be wrapped
jArr.putAll(new JSONArray(new SomeBean[]{ new SomeBean(3), new
SomeBean(4) }));
// our jArr is now consistent.
```addAll methods to have optional wrapping.1 parent 5d828d2 commit f35194b
1 file changed
Lines changed: 46 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
1209 | | - | |
| 1209 | + | |
1210 | 1210 | | |
1211 | 1211 | | |
1212 | 1212 | | |
| |||
1218 | 1218 | | |
1219 | 1219 | | |
1220 | 1220 | | |
1221 | | - | |
| 1221 | + | |
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| |||
1250 | 1250 | | |
1251 | 1251 | | |
1252 | 1252 | | |
1253 | | - | |
| 1253 | + | |
1254 | 1254 | | |
1255 | 1255 | | |
1256 | 1256 | | |
| |||
1585 | 1585 | | |
1586 | 1586 | | |
1587 | 1587 | | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
1588 | 1592 | | |
1589 | | - | |
| 1593 | + | |
1590 | 1594 | | |
1591 | | - | |
1592 | | - | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
1593 | 1603 | | |
1594 | 1604 | | |
1595 | 1605 | | |
| |||
1598 | 1608 | | |
1599 | 1609 | | |
1600 | 1610 | | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
1605 | 1624 | | |
1606 | 1625 | | |
1607 | 1626 | | |
| |||
1612 | 1631 | | |
1613 | 1632 | | |
1614 | 1633 | | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
1615 | 1637 | | |
1616 | 1638 | | |
1617 | 1639 | | |
1618 | 1640 | | |
1619 | 1641 | | |
1620 | 1642 | | |
1621 | | - | |
| 1643 | + | |
1622 | 1644 | | |
1623 | 1645 | | |
1624 | 1646 | | |
1625 | | - | |
1626 | | - | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
1627 | 1655 | | |
1628 | 1656 | | |
1629 | 1657 | | |
1630 | 1658 | | |
1631 | 1659 | | |
1632 | 1660 | | |
1633 | 1661 | | |
1634 | | - | |
| 1662 | + | |
1635 | 1663 | | |
1636 | | - | |
| 1664 | + | |
1637 | 1665 | | |
1638 | 1666 | | |
1639 | 1667 | | |
| |||
0 commit comments