diff --git a/JSONObject.java b/JSONObject.java index d666231..e28c9cd 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -91,7 +91,7 @@ import java.util.Set; * * * @author JSON.org - * @version 2014-05-03 + * @version 2015-05-05 */ public class JSONObject { /** @@ -298,7 +298,7 @@ public class JSONObject { */ public JSONObject(Object object, String names[]) { this(); - Class c = object.getClass(); + Class c = object.getClass(); for (int i = 0; i < names.length; i += 1) { String name = names[i]; try { @@ -631,7 +631,7 @@ public class JSONObject { if (object == null) { return null; } - Class klass = object.getClass(); + Class klass = object.getClass(); Field[] fields = klass.getFields(); int length = fields.length; if (length == 0) { @@ -981,7 +981,7 @@ public class JSONObject { } private void populateMap(Object bean) { - Class klass = bean.getClass(); + Class klass = bean.getClass(); // If klass is a System class then set includeSuperClass to false. @@ -1512,10 +1512,14 @@ public class JSONObject { return value.toString(); } if (value instanceof Map) { - return new JSONObject((Map)value).toString(); + @SuppressWarnings("unchecked") + Map map = (Map) value; + return new JSONObject(map).toString(); } if (value instanceof Collection) { - return new JSONArray((Collection) value).toString(); + @SuppressWarnings("unchecked") + Collection coll = (Collection) value; + return new JSONArray(coll).toString(); } if (value.getClass().isArray()) { return new JSONArray(value).toString(); @@ -1551,13 +1555,17 @@ public class JSONObject { } if (object instanceof Collection) { - return new JSONArray((Collection) object); + @SuppressWarnings("unchecked") + Collection coll = (Collection) object; + return new JSONArray(coll); } if (object.getClass().isArray()) { return new JSONArray(object); } if (object instanceof Map) { - return new JSONObject((Map) object); + @SuppressWarnings("unchecked") + Map map = (Map) object; + return new JSONObject(map); } Package objectPackage = object.getClass().getPackage(); String objectPackageName = objectPackage != null ? objectPackage @@ -1595,9 +1603,13 @@ public class JSONObject { } else if (value instanceof JSONArray) { ((JSONArray) value).write(writer, indentFactor, indent); } else if (value instanceof Map) { - new JSONObject((Map) value).write(writer, indentFactor, indent); + @SuppressWarnings("unchecked") + Map map = (Map) value; + new JSONObject(map).write(writer, indentFactor, indent); } else if (value instanceof Collection) { - new JSONArray((Collection) value).write(writer, indentFactor, + @SuppressWarnings("unchecked") + Collection coll = (Collection) value; + new JSONArray(coll).write(writer, indentFactor, indent); } else if (value.getClass().isArray()) { new JSONArray(value).write(writer, indentFactor, indent); diff --git a/Property.java b/Property.java index 8122241..73ddb12 100644 --- a/Property.java +++ b/Property.java @@ -31,7 +31,7 @@ import java.util.Properties; /** * Converts a Property file data into JSONObject and back. * @author JSON.org - * @version 2014-05-03 + * @version 2015-05-05 */ public class Property { /** @@ -43,7 +43,7 @@ public class Property { public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException { JSONObject jo = new JSONObject(); if (properties != null && !properties.isEmpty()) { - Enumeration enumProperties = properties.propertyNames(); + Enumeration enumProperties = properties.propertyNames(); while(enumProperties.hasMoreElements()) { String name = (String)enumProperties.nextElement(); jo.put(name, properties.getProperty(name));