@@ -91,7 +91,7 @@ of this software and associated documentation files (the "Software"), to deal
91
91
* </ul>
92
92
*
93
93
* @author JSON.org
94
- * @version 2014 -05-03
94
+ * @version 2015 -05-05
95
95
*/
96
96
public class JSONObject {
97
97
/**
@@ -298,7 +298,7 @@ public JSONObject(Object bean) {
298
298
*/
299
299
public JSONObject (Object object , String names []) {
300
300
this ();
301
- Class c = object .getClass ();
301
+ Class <?> c = object .getClass ();
302
302
for (int i = 0 ; i < names .length ; i += 1 ) {
303
303
String name = names [i ];
304
304
try {
@@ -631,7 +631,7 @@ public static String[] getNames(Object object) {
631
631
if (object == null ) {
632
632
return null ;
633
633
}
634
- Class klass = object .getClass ();
634
+ Class <?> klass = object .getClass ();
635
635
Field [] fields = klass .getFields ();
636
636
int length = fields .length ;
637
637
if (length == 0 ) {
@@ -981,7 +981,7 @@ public String optString(String key, String defaultValue) {
981
981
}
982
982
983
983
private void populateMap (Object bean ) {
984
- Class klass = bean .getClass ();
984
+ Class <?> klass = bean .getClass ();
985
985
986
986
// If klass is a System class then set includeSuperClass to false.
987
987
@@ -1512,10 +1512,14 @@ public static String valueToString(Object value) throws JSONException {
1512
1512
return value .toString ();
1513
1513
}
1514
1514
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 ();
1516
1518
}
1517
1519
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 ();
1519
1523
}
1520
1524
if (value .getClass ().isArray ()) {
1521
1525
return new JSONArray (value ).toString ();
@@ -1551,13 +1555,17 @@ public static Object wrap(Object object) {
1551
1555
}
1552
1556
1553
1557
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 );
1555
1561
}
1556
1562
if (object .getClass ().isArray ()) {
1557
1563
return new JSONArray (object );
1558
1564
}
1559
1565
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 );
1561
1569
}
1562
1570
Package objectPackage = object .getClass ().getPackage ();
1563
1571
String objectPackageName = objectPackage != null ? objectPackage
@@ -1595,9 +1603,13 @@ static final Writer writeValue(Writer writer, Object value,
1595
1603
} else if (value instanceof JSONArray ) {
1596
1604
((JSONArray ) value ).write (writer , indentFactor , indent );
1597
1605
} 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 );
1599
1609
} 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 ,
1601
1613
indent );
1602
1614
} else if (value .getClass ().isArray ()) {
1603
1615
new JSONArray (value ).write (writer , indentFactor , indent );
0 commit comments