@@ -243,15 +243,13 @@ public JSONObject(JSONTokener x) throws JSONException {
243243 * the JSONObject.
244244 * @throws JSONException
245245 */
246- public JSONObject (Map <String , Object > map ) {
246+ public JSONObject (Map <?, ? > map ) {
247247 this .map = new HashMap <String , Object >();
248248 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 ();
253251 if (value != null ) {
254- this .map .put (entry . getKey (), wrap (value ));
252+ this .map .put (String . valueOf ( e . getKey () ), wrap (value ));
255253 }
256254 }
257255 }
@@ -1204,7 +1202,7 @@ public JSONObject put(String key, boolean value) throws JSONException {
12041202 * @return this.
12051203 * @throws JSONException
12061204 */
1207- public JSONObject put (String key , Collection <Object > value ) throws JSONException {
1205+ public JSONObject put (String key , Collection <? > value ) throws JSONException {
12081206 this .put (key , new JSONArray (value ));
12091207 return this ;
12101208 }
@@ -1268,7 +1266,7 @@ public JSONObject put(String key, long value) throws JSONException {
12681266 * @return this.
12691267 * @throws JSONException
12701268 */
1271- public JSONObject put (String key , Map <String , Object > value ) throws JSONException {
1269+ public JSONObject put (String key , Map <?, ? > value ) throws JSONException {
12721270 this .put (key , new JSONObject (value ));
12731271 return this ;
12741272 }
@@ -1663,13 +1661,11 @@ public static String valueToString(Object value) throws JSONException {
16631661 return value .toString ();
16641662 }
16651663 if (value instanceof Map ) {
1666- @ SuppressWarnings ("unchecked" )
1667- Map <String , Object > map = (Map <String , Object >) value ;
1664+ Map <?, ?> map = (Map <?, ?>) value ;
16681665 return new JSONObject (map ).toString ();
16691666 }
16701667 if (value instanceof Collection ) {
1671- @ SuppressWarnings ("unchecked" )
1672- Collection <Object > coll = (Collection <Object >) value ;
1668+ Collection <?> coll = (Collection <?>) value ;
16731669 return new JSONArray (coll ).toString ();
16741670 }
16751671 if (value .getClass ().isArray ()) {
@@ -1707,16 +1703,14 @@ public static Object wrap(Object object) {
17071703 }
17081704
17091705 if (object instanceof Collection ) {
1710- @ SuppressWarnings ("unchecked" )
1711- Collection <Object > coll = (Collection <Object >) object ;
1706+ Collection <?> coll = (Collection <?>) object ;
17121707 return new JSONArray (coll );
17131708 }
17141709 if (object .getClass ().isArray ()) {
17151710 return new JSONArray (object );
17161711 }
17171712 if (object instanceof Map ) {
1718- @ SuppressWarnings ("unchecked" )
1719- Map <String , Object > map = (Map <String , Object >) object ;
1713+ Map <?, ?> map = (Map <?, ?>) object ;
17201714 return new JSONObject (map );
17211715 }
17221716 Package objectPackage = object .getClass ().getPackage ();
@@ -1755,14 +1749,11 @@ static final Writer writeValue(Writer writer, Object value,
17551749 } else if (value instanceof JSONArray ) {
17561750 ((JSONArray ) value ).write (writer , indentFactor , indent );
17571751 } else if (value instanceof Map ) {
1758- @ SuppressWarnings ("unchecked" )
1759- Map <String , Object > map = (Map <String , Object >) value ;
1752+ Map <?, ?> map = (Map <?, ?>) value ;
17601753 new JSONObject (map ).write (writer , indentFactor , indent );
17611754 } 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 );
17661757 } else if (value .getClass ().isArray ()) {
17671758 new JSONArray (value ).write (writer , indentFactor , indent );
17681759 } else if (value instanceof Number ) {
0 commit comments