From 2a4bc3420acc10e30d99841279164d195d2a525e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Tue, 1 Aug 2023 14:38:45 -0700 Subject: [PATCH] Apply simplification suggested by @johnjaylward. --- src/main/java/org/json/JSONObject.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 '}':