Skip to content

Commit 5b18f02

Browse files
null first
1 parent f9ef032 commit 5b18f02

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

JSONObject.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ of this software and associated documentation files (the "Software"), to deal
9090
* </ul>
9191
*
9292
* @author JSON.org
93-
* @version 2012-04-20
93+
* @version 2012-05-29
9494
*/
9595
public class JSONObject {
9696

@@ -1497,7 +1497,9 @@ public Writer write(Writer writer) throws JSONException {
14971497

14981498
static final Writer writeValue(Writer writer, Object value,
14991499
int indentFactor, int indent) throws JSONException, IOException {
1500-
if (value instanceof JSONObject) {
1500+
if (value == null || value.equals(null)) {
1501+
writer.write("null");
1502+
} else if (value instanceof JSONObject) {
15011503
((JSONObject) value).write(writer, indentFactor, indent);
15021504
} else if (value instanceof JSONArray) {
15031505
((JSONArray) value).write(writer, indentFactor, indent);
@@ -1520,8 +1522,6 @@ static final Writer writeValue(Writer writer, Object value,
15201522
throw new JSONException(e);
15211523
}
15221524
writer.write(o != null ? o.toString() : quote(value.toString()));
1523-
} else if (value == null || value.equals(null)) {
1524-
writer.write("null");
15251525
} else {
15261526
quote(value.toString(), writer);
15271527
}

0 commit comments

Comments
 (0)