@@ -243,17 +243,13 @@ public JSONObject(JSONTokener x) throws JSONException {
243243 * the JSONObject.
244244 * @throws JSONException
245245 */
246- public JSONObject (Map <String , ?> map ) {
246+ public JSONObject (Map <? , ?> map ) {
247247 this .map = new HashMap <String , Object >();
248248 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 ();
255251 if (value != null ) {
256- this .map .put (entry . getKey (), wrap (value ));
252+ this .map .put (String . valueOf ( e . getKey () ), wrap (value ));
257253 }
258254 }
259255 }
@@ -1270,7 +1266,7 @@ public JSONObject put(String key, long value) throws JSONException {
12701266 * @return this.
12711267 * @throws JSONException
12721268 */
1273- public JSONObject put (String key , Map <String , ?> value ) throws JSONException {
1269+ public JSONObject put (String key , Map <? , ?> value ) throws JSONException {
12741270 this .put (key , new JSONObject (value ));
12751271 return this ;
12761272 }
@@ -1666,7 +1662,7 @@ public static String valueToString(Object value) throws JSONException {
16661662 }
16671663 if (value instanceof Map ) {
16681664 @ SuppressWarnings ("unchecked" )
1669- Map <String , ?> map = (Map <String , ?>) value ;
1665+ Map <? , ?> map = (Map <? , ?>) value ;
16701666 return new JSONObject (map ).toString ();
16711667 }
16721668 if (value instanceof Collection ) {
@@ -1718,7 +1714,7 @@ public static Object wrap(Object object) {
17181714 }
17191715 if (object instanceof Map ) {
17201716 @ SuppressWarnings ("unchecked" )
1721- Map <String , ?> map = (Map <String , ?>) object ;
1717+ Map <? , ?> map = (Map <? , ?>) object ;
17221718 return new JSONObject (map );
17231719 }
17241720 Package objectPackage = object .getClass ().getPackage ();
@@ -1758,7 +1754,7 @@ static final Writer writeValue(Writer writer, Object value,
17581754 ((JSONArray ) value ).write (writer , indentFactor , indent );
17591755 } else if (value instanceof Map ) {
17601756 @ SuppressWarnings ("unchecked" )
1761- Map <String , ?> map = (Map <String , ?>) value ;
1757+ Map <? , ?> map = (Map <? , ?>) value ;
17621758 new JSONObject (map ).write (writer , indentFactor , indent );
17631759 } else if (value instanceof Collection ) {
17641760 @ SuppressWarnings ("unchecked" )
0 commit comments