@@ -243,15 +243,13 @@ public JSONObject(JSONTokener x) throws JSONException {
243
243
* the JSONObject.
244
244
* @throws JSONException
245
245
*/
246
- public JSONObject (Map <String , Object > map ) {
246
+ public JSONObject (Map <?, ? > map ) {
247
247
this .map = new HashMap <String , Object >();
248
248
if (map != null ) {
249
- Iterator <Entry <String , Object >> i = map .entrySet ().iterator ();
250
- while (i .hasNext ()) {
251
- Entry <String , Object > entry = i .next ();
252
- Object value = entry .getValue ();
249
+ for (final Entry <?, ?> e : map .entrySet ()) {
250
+ final Object value = e .getValue ();
253
251
if (value != null ) {
254
- this .map .put (entry . getKey (), wrap (value ));
252
+ this .map .put (String . valueOf ( e . getKey () ), wrap (value ));
255
253
}
256
254
}
257
255
}
@@ -1204,7 +1202,7 @@ public JSONObject put(String key, boolean value) throws JSONException {
1204
1202
* @return this.
1205
1203
* @throws JSONException
1206
1204
*/
1207
- public JSONObject put (String key , Collection <Object > value ) throws JSONException {
1205
+ public JSONObject put (String key , Collection <? > value ) throws JSONException {
1208
1206
this .put (key , new JSONArray (value ));
1209
1207
return this ;
1210
1208
}
@@ -1268,7 +1266,7 @@ public JSONObject put(String key, long value) throws JSONException {
1268
1266
* @return this.
1269
1267
* @throws JSONException
1270
1268
*/
1271
- public JSONObject put (String key , Map <String , Object > value ) throws JSONException {
1269
+ public JSONObject put (String key , Map <?, ? > value ) throws JSONException {
1272
1270
this .put (key , new JSONObject (value ));
1273
1271
return this ;
1274
1272
}
@@ -1663,13 +1661,11 @@ public static String valueToString(Object value) throws JSONException {
1663
1661
return value .toString ();
1664
1662
}
1665
1663
if (value instanceof Map ) {
1666
- @ SuppressWarnings ("unchecked" )
1667
- Map <String , Object > map = (Map <String , Object >) value ;
1664
+ Map <?, ?> map = (Map <?, ?>) value ;
1668
1665
return new JSONObject (map ).toString ();
1669
1666
}
1670
1667
if (value instanceof Collection ) {
1671
- @ SuppressWarnings ("unchecked" )
1672
- Collection <Object > coll = (Collection <Object >) value ;
1668
+ Collection <?> coll = (Collection <?>) value ;
1673
1669
return new JSONArray (coll ).toString ();
1674
1670
}
1675
1671
if (value .getClass ().isArray ()) {
@@ -1707,16 +1703,14 @@ public static Object wrap(Object object) {
1707
1703
}
1708
1704
1709
1705
if (object instanceof Collection ) {
1710
- @ SuppressWarnings ("unchecked" )
1711
- Collection <Object > coll = (Collection <Object >) object ;
1706
+ Collection <?> coll = (Collection <?>) object ;
1712
1707
return new JSONArray (coll );
1713
1708
}
1714
1709
if (object .getClass ().isArray ()) {
1715
1710
return new JSONArray (object );
1716
1711
}
1717
1712
if (object instanceof Map ) {
1718
- @ SuppressWarnings ("unchecked" )
1719
- Map <String , Object > map = (Map <String , Object >) object ;
1713
+ Map <?, ?> map = (Map <?, ?>) object ;
1720
1714
return new JSONObject (map );
1721
1715
}
1722
1716
Package objectPackage = object .getClass ().getPackage ();
@@ -1755,14 +1749,11 @@ static final Writer writeValue(Writer writer, Object value,
1755
1749
} else if (value instanceof JSONArray ) {
1756
1750
((JSONArray ) value ).write (writer , indentFactor , indent );
1757
1751
} else if (value instanceof Map ) {
1758
- @ SuppressWarnings ("unchecked" )
1759
- Map <String , Object > map = (Map <String , Object >) value ;
1752
+ Map <?, ?> map = (Map <?, ?>) value ;
1760
1753
new JSONObject (map ).write (writer , indentFactor , indent );
1761
1754
} else if (value instanceof Collection ) {
1762
- @ SuppressWarnings ("unchecked" )
1763
- Collection <Object > coll = (Collection <Object >) value ;
1764
- new JSONArray (coll ).write (writer , indentFactor ,
1765
- indent );
1755
+ Collection <?> coll = (Collection <?>) value ;
1756
+ new JSONArray (coll ).write (writer , indentFactor , indent );
1766
1757
} else if (value .getClass ().isArray ()) {
1767
1758
new JSONArray (value ).write (writer , indentFactor , indent );
1768
1759
} else if (value instanceof Number ) {
0 commit comments