|
|
@@ -134,6 +134,11 @@ public class JSONObject
|
|
|
return val;
|
|
|
}
|
|
|
|
|
|
+ public JSONObject getJSONObjectValue(String key, JSONObject defaultvalue) {
|
|
|
+ JSONObject jsonObject = getJSONObject(key);
|
|
|
+ return jsonObject == null ? defaultvalue : jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
public JSONObject getJSONObject(String key) {
|
|
|
Object value = map.get(key);
|
|
|
if (value instanceof JSONObject) {
|
|
|
@@ -415,6 +420,9 @@ public class JSONObject
|
|
|
}
|
|
|
|
|
|
public boolean getBooleanValue(String key) {
|
|
|
+ if (getStringValue(key).equals("1")) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
return getBooleanValue(key, false);
|
|
|
}
|
|
|
|
|
|
@@ -1000,7 +1008,7 @@ public class JSONObject
|
|
|
String name = null;
|
|
|
JSONField annotation = method.getAnnotation(JSONField.class);
|
|
|
if (annotation != null) {
|
|
|
- if (annotation.name().length() != 0) {
|
|
|
+ if (!annotation.name().isEmpty()) {
|
|
|
name = annotation.name();
|
|
|
}
|
|
|
}
|
|
|
@@ -1013,7 +1021,7 @@ public class JSONObject
|
|
|
}
|
|
|
|
|
|
name = name.substring(3);
|
|
|
- if (name.length() == 0) {
|
|
|
+ if (name.isEmpty()) {
|
|
|
throw new JSONException("illegal setter");
|
|
|
}
|
|
|
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
|
|
|
@@ -1032,7 +1040,7 @@ public class JSONObject
|
|
|
String name = null;
|
|
|
JSONField annotation = method.getAnnotation(JSONField.class);
|
|
|
if (annotation != null) {
|
|
|
- if (annotation.name().length() != 0) {
|
|
|
+ if (!annotation.name().isEmpty()) {
|
|
|
name = annotation.name();
|
|
|
}
|
|
|
}
|
|
|
@@ -1041,13 +1049,13 @@ public class JSONObject
|
|
|
name = method.getName();
|
|
|
if (name.startsWith("get")) {
|
|
|
name = name.substring(3);
|
|
|
- if (name.length() == 0) {
|
|
|
+ if (name.isEmpty()) {
|
|
|
throw new JSONException("illegal getter");
|
|
|
}
|
|
|
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
|
|
|
} else if (name.startsWith("is")) {
|
|
|
name = name.substring(2);
|
|
|
- if (name.length() == 0) {
|
|
|
+ if (name.isEmpty()) {
|
|
|
throw new JSONException("illegal getter");
|
|
|
}
|
|
|
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
|