fix: config check and restore
This commit is contained in:
@@ -215,25 +215,19 @@ public class Config {
|
|||||||
cur = new JSONObject();
|
cur = new JSONObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray names = json.names();
|
for(String key : json.keySet()) {
|
||||||
int len = names.length();
|
Object defVal = json.opt(key);
|
||||||
|
Object curVal = cur.opt(key);
|
||||||
for (int i = 0; i < len; i++) {
|
if (defVal != null) {
|
||||||
String key = names.optString(i);
|
if (defVal instanceof JSONObject) {
|
||||||
if (key != null) {
|
cur.put(key, checkAndRestoreRecursive((JSONObject) defVal, cur.optJSONObject(key)));
|
||||||
Object defVal = json.opt(key);
|
} else {
|
||||||
Object curVal = cur.opt(key);
|
if (curVal != null) {
|
||||||
if (defVal != null) {
|
if (curVal.getClass() != defVal.getClass()) {
|
||||||
if (defVal instanceof JSONObject) {
|
|
||||||
cur.put(key, checkAndRestoreRecursive((JSONObject) defVal, cur.optJSONObject(key)));
|
|
||||||
} else {
|
|
||||||
if (curVal != null) {
|
|
||||||
if (curVal.getClass() != defVal.getClass()) {
|
|
||||||
cur.put(key, defVal);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cur.put(key, defVal);
|
cur.put(key, defVal);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cur.put(key, defVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user