1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-16 23:40:51 -07:00

Replaced tab chars, updated versions

This commit is contained in:
stleary 2015-05-05 20:11:28 -05:00
parent b56fe9fea9
commit a851bf0951
2 changed files with 24 additions and 12 deletions

View file

@ -91,7 +91,7 @@ import java.util.Set;
* </ul>
*
* @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<String, Object>)value).toString();
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) value;
return new JSONObject(map).toString();
}
if (value instanceof Collection) {
return new JSONArray((Collection<Object>) value).toString();
@SuppressWarnings("unchecked")
Collection<Object> coll = (Collection<Object>) 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>) object);
@SuppressWarnings("unchecked")
Collection<Object> coll = (Collection<Object>) object;
return new JSONArray(coll);
}
if (object.getClass().isArray()) {
return new JSONArray(object);
}
if (object instanceof Map) {
return new JSONObject((Map<String, Object>) object);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) 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<String, Object>) value).write(writer, indentFactor, indent);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) value;
new JSONObject(map).write(writer, indentFactor, indent);
} else if (value instanceof Collection) {
new JSONArray((Collection<Object>) value).write(writer, indentFactor,
@SuppressWarnings("unchecked")
Collection<Object> coll = (Collection<Object>) value;
new JSONArray(coll).write(writer, indentFactor,
indent);
} else if (value.getClass().isArray()) {
new JSONArray(value).write(writer, indentFactor, indent);

View file

@ -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));