mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-24 00:03:17 -05:00
Updating to work with java 1.6
This commit is contained in:
@@ -3296,7 +3296,6 @@ public class JSONObject {
|
|||||||
if (has(fieldName)) {
|
if (has(fieldName)) {
|
||||||
Object value = get(fieldName);
|
Object value = get(fieldName);
|
||||||
Type fieldType = field.getGenericType();
|
Type fieldType = field.getGenericType();
|
||||||
Class<?> rawType = getRawType(fieldType);
|
|
||||||
Object convertedValue = convertValue(value, fieldType);
|
Object convertedValue = convertValue(value, fieldType);
|
||||||
field.set(obj, convertedValue);
|
field.set(obj, convertedValue);
|
||||||
}
|
}
|
||||||
@@ -3333,9 +3332,9 @@ public class JSONObject {
|
|||||||
} else if (rawType == long.class || rawType == Long.class) {
|
} else if (rawType == long.class || rawType == Long.class) {
|
||||||
return ((Number) value).longValue();
|
return ((Number) value).longValue();
|
||||||
} else if (rawType == boolean.class || rawType == Boolean.class) {
|
} else if (rawType == boolean.class || rawType == Boolean.class) {
|
||||||
return (Boolean) value;
|
return value;
|
||||||
} else if (rawType == String.class) {
|
} else if (rawType == String.class) {
|
||||||
return (String) value;
|
return value;
|
||||||
} else if (rawType == BigDecimal.class) {
|
} else if (rawType == BigDecimal.class) {
|
||||||
return new BigDecimal((String) value);
|
return new BigDecimal((String) value);
|
||||||
} else if (rawType == BigInteger.class) {
|
} else if (rawType == BigInteger.class) {
|
||||||
@@ -3353,14 +3352,14 @@ public class JSONObject {
|
|||||||
Type elementType = getElementType(targetType);
|
Type elementType = getElementType(targetType);
|
||||||
return fromJsonArray((JSONArray) value, rawType, elementType);
|
return fromJsonArray((JSONArray) value, rawType, elementType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Map handling (e.g., Map<Integer, List<String>>)
|
// Map handling (e.g., Map<Integer, List<String>>)
|
||||||
else if (Map.class.isAssignableFrom(rawType) && value instanceof JSONObject) {
|
else if (Map.class.isAssignableFrom(rawType) && value instanceof JSONObject) {
|
||||||
Type[] mapTypes = getMapTypes(targetType);
|
Type[] mapTypes = getMapTypes(targetType);
|
||||||
Type keyType = mapTypes[0];
|
Type keyType = mapTypes[0];
|
||||||
Type valueType = mapTypes[1];
|
Type valueType = mapTypes[1];
|
||||||
return convertToMap((JSONObject) value, keyType, valueType, rawType);
|
return convertToMap((JSONObject) value, keyType, valueType, rawType);
|
||||||
}
|
}
|
||||||
// POJO handling (including custom classes like Tuple<Integer, String, Integer>)
|
// POJO handling (including custom classes like Tuple<Integer, String, Integer>)
|
||||||
else if (!rawType.isPrimitive() && !rawType.isEnum() && value instanceof JSONObject) {
|
else if (!rawType.isPrimitive() && !rawType.isEnum() && value instanceof JSONObject) {
|
||||||
// Recurse with the raw class for POJO deserialization
|
// Recurse with the raw class for POJO deserialization
|
||||||
|
|||||||
Reference in New Issue
Block a user