@@ -91,7 +91,7 @@ of this software and associated documentation files (the "Software"), to deal
9191 * </ul>
9292 *
9393 * @author JSON.org
94- * @version 2014 -05-03
94+ * @version 2015 -05-05
9595 */
9696public class JSONObject {
9797 /**
@@ -298,7 +298,7 @@ public JSONObject(Object bean) {
298298 */
299299 public JSONObject (Object object , String names []) {
300300 this ();
301- Class c = object .getClass ();
301+ Class <?> c = object .getClass ();
302302 for (int i = 0 ; i < names .length ; i += 1 ) {
303303 String name = names [i ];
304304 try {
@@ -631,7 +631,7 @@ public static String[] getNames(Object object) {
631631 if (object == null ) {
632632 return null ;
633633 }
634- Class klass = object .getClass ();
634+ Class <?> klass = object .getClass ();
635635 Field [] fields = klass .getFields ();
636636 int length = fields .length ;
637637 if (length == 0 ) {
@@ -981,7 +981,7 @@ public String optString(String key, String defaultValue) {
981981 }
982982
983983 private void populateMap (Object bean ) {
984- Class klass = bean .getClass ();
984+ Class <?> klass = bean .getClass ();
985985
986986// If klass is a System class then set includeSuperClass to false.
987987
@@ -1512,10 +1512,14 @@ public static String valueToString(Object value) throws JSONException {
15121512 return value .toString ();
15131513 }
15141514 if (value instanceof Map ) {
1515- return new JSONObject ((Map <String , Object >)value ).toString ();
1515+ @ SuppressWarnings ("unchecked" )
1516+ Map <String , Object > map = (Map <String , Object >) value ;
1517+ return new JSONObject (map ).toString ();
15161518 }
15171519 if (value instanceof Collection ) {
1518- return new JSONArray ((Collection <Object >) value ).toString ();
1520+ @ SuppressWarnings ("unchecked" )
1521+ Collection <Object > coll = (Collection <Object >) value ;
1522+ return new JSONArray (coll ).toString ();
15191523 }
15201524 if (value .getClass ().isArray ()) {
15211525 return new JSONArray (value ).toString ();
@@ -1551,13 +1555,17 @@ public static Object wrap(Object object) {
15511555 }
15521556
15531557 if (object instanceof Collection ) {
1554- return new JSONArray ((Collection <Object >) object );
1558+ @ SuppressWarnings ("unchecked" )
1559+ Collection <Object > coll = (Collection <Object >) object ;
1560+ return new JSONArray (coll );
15551561 }
15561562 if (object .getClass ().isArray ()) {
15571563 return new JSONArray (object );
15581564 }
15591565 if (object instanceof Map ) {
1560- return new JSONObject ((Map <String , Object >) object );
1566+ @ SuppressWarnings ("unchecked" )
1567+ Map <String , Object > map = (Map <String , Object >) object ;
1568+ return new JSONObject (map );
15611569 }
15621570 Package objectPackage = object .getClass ().getPackage ();
15631571 String objectPackageName = objectPackage != null ? objectPackage
@@ -1595,9 +1603,13 @@ static final Writer writeValue(Writer writer, Object value,
15951603 } else if (value instanceof JSONArray ) {
15961604 ((JSONArray ) value ).write (writer , indentFactor , indent );
15971605 } else if (value instanceof Map ) {
1598- new JSONObject ((Map <String , Object >) value ).write (writer , indentFactor , indent );
1606+ @ SuppressWarnings ("unchecked" )
1607+ Map <String , Object > map = (Map <String , Object >) value ;
1608+ new JSONObject (map ).write (writer , indentFactor , indent );
15991609 } else if (value instanceof Collection ) {
1600- new JSONArray ((Collection <Object >) value ).write (writer , indentFactor ,
1610+ @ SuppressWarnings ("unchecked" )
1611+ Collection <Object > coll = (Collection <Object >) value ;
1612+ new JSONArray (coll ).write (writer , indentFactor ,
16011613 indent );
16021614 } else if (value .getClass ().isArray ()) {
16031615 new JSONArray (value ).write (writer , indentFactor , indent );
0 commit comments