From 5b18f02eeedcdab344b34979372483050de13823 Mon Sep 17 00:00:00 2001 From: Douglas Crockford Date: Wed, 30 May 2012 10:22:09 -0700 Subject: [PATCH] null first --- JSONObject.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/JSONObject.java b/JSONObject.java index 5b05255..f41582c 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -90,7 +90,7 @@ import java.util.ResourceBundle; * * * @author JSON.org - * @version 2012-04-20 + * @version 2012-05-29 */ public class JSONObject { @@ -1497,7 +1497,9 @@ public class JSONObject { static final Writer writeValue(Writer writer, Object value, int indentFactor, int indent) throws JSONException, IOException { - if (value instanceof JSONObject) { + if (value == null || value.equals(null)) { + writer.write("null"); + } else if (value instanceof JSONObject) { ((JSONObject) value).write(writer, indentFactor, indent); } else if (value instanceof JSONArray) { ((JSONArray) value).write(writer, indentFactor, indent); @@ -1520,8 +1522,6 @@ public class JSONObject { throw new JSONException(e); } writer.write(o != null ? o.toString() : quote(value.toString())); - } else if (value == null || value.equals(null)) { - writer.write("null"); } else { quote(value.toString(), writer); }