diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index 4c08b0b9c..7a73fbf22 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -2701,6 +2701,7 @@ static final Writer writeValue(Writer writer, Object value, 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 below Object o; try { o = ((JSONString) value).toJSONString();