@@ -243,17 +243,13 @@ public JSONObject(JSONTokener x) throws JSONException {
243
243
* the JSONObject.
244
244
* @throws JSONException
245
245
*/
246
- public JSONObject (Map <String , ?> map ) {
246
+ public JSONObject (Map <? , ?> map ) {
247
247
this .map = new HashMap <String , Object >();
248
248
if (map != null ) {
249
- Set <?> eSet = map .entrySet ();
250
- @ SuppressWarnings ("unchecked" )
251
- Iterator <Entry <String , ?>> i = (Iterator <Entry <String , ?>>) eSet .iterator ();
252
- while (i .hasNext ()) {
253
- Entry <String , ?> entry = i .next ();
254
- Object value = entry .getValue ();
249
+ for (final Entry <?, ?> e : map .entrySet ()) {
250
+ final Object value = e .getValue ();
255
251
if (value != null ) {
256
- this .map .put (entry . getKey (), wrap (value ));
252
+ this .map .put (String . valueOf ( e . getKey () ), wrap (value ));
257
253
}
258
254
}
259
255
}
@@ -1270,7 +1266,7 @@ public JSONObject put(String key, long value) throws JSONException {
1270
1266
* @return this.
1271
1267
* @throws JSONException
1272
1268
*/
1273
- public JSONObject put (String key , Map <String , ?> value ) throws JSONException {
1269
+ public JSONObject put (String key , Map <? , ?> value ) throws JSONException {
1274
1270
this .put (key , new JSONObject (value ));
1275
1271
return this ;
1276
1272
}
@@ -1666,7 +1662,7 @@ public static String valueToString(Object value) throws JSONException {
1666
1662
}
1667
1663
if (value instanceof Map ) {
1668
1664
@ SuppressWarnings ("unchecked" )
1669
- Map <String , ?> map = (Map <String , ?>) value ;
1665
+ Map <? , ?> map = (Map <? , ?>) value ;
1670
1666
return new JSONObject (map ).toString ();
1671
1667
}
1672
1668
if (value instanceof Collection ) {
@@ -1718,7 +1714,7 @@ public static Object wrap(Object object) {
1718
1714
}
1719
1715
if (object instanceof Map ) {
1720
1716
@ SuppressWarnings ("unchecked" )
1721
- Map <String , ?> map = (Map <String , ?>) object ;
1717
+ Map <? , ?> map = (Map <? , ?>) object ;
1722
1718
return new JSONObject (map );
1723
1719
}
1724
1720
Package objectPackage = object .getClass ().getPackage ();
@@ -1758,7 +1754,7 @@ static final Writer writeValue(Writer writer, Object value,
1758
1754
((JSONArray ) value ).write (writer , indentFactor , indent );
1759
1755
} else if (value instanceof Map ) {
1760
1756
@ SuppressWarnings ("unchecked" )
1761
- Map <String , ?> map = (Map <String , ?>) value ;
1757
+ Map <? , ?> map = (Map <? , ?>) value ;
1762
1758
new JSONObject (map ).write (writer , indentFactor , indent );
1763
1759
} else if (value instanceof Collection ) {
1764
1760
@ SuppressWarnings ("unchecked" )
0 commit comments