diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index 36f02d6c2..5e00eb9a3 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -253,13 +253,12 @@ public JSONObject(JSONTokener x) throws JSONException { switch (x.nextClean()) { case ';': case ',': - c = x.nextClean(); - if (c == 0) { - throw x.syntaxError("A JSONObject text must end with '}'"); - } - if (c == '}') { + if (x.nextClean() == '}') { return; } + if (x.end()) { + throw x.syntaxError("A JSONObject text must end with '}'"); + } x.back(); break; case '}':