mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
#863 fix changed behaviour of changing order in writeValue with JSONString
This commit is contained in:
parent
d878c38d40
commit
4f456d9432
@ -2705,6 +2705,15 @@ public class JSONObject {
|
||||
int indentFactor, int indent) throws JSONException, IOException {
|
||||
if (value == null || value.equals(null)) {
|
||||
writer.write("null");
|
||||
} else if (value instanceof JSONString) {
|
||||
// JSONString must be checked first, so it can overwrite behaviour of other types
|
||||
Object o;
|
||||
try {
|
||||
o = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
writer.write(o != null ? o.toString() : quote(value.toString()));
|
||||
} else if (value instanceof String) {
|
||||
// assuming most values are Strings, so testing it early
|
||||
quote(value.toString(), writer);
|
||||
@ -2733,14 +2742,6 @@ public class JSONObject {
|
||||
new JSONArray(coll).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Enum<?>) {
|
||||
writer.write(quote(((Enum<?>)value).name()));
|
||||
} else if (value instanceof JSONString) {
|
||||
Object o;
|
||||
try {
|
||||
o = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
writer.write(o != null ? o.toString() : quote(value.toString()));
|
||||
} else if (value.getClass().isArray()) {
|
||||
new JSONArray(value).write(writer, indentFactor, indent);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user