diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/JSONArray.java index fe56b50e9..5b3cb2bdc 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/main/java/org/json/JSONArray.java @@ -115,24 +115,24 @@ public JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration) this.myArrayList.add(x.nextValue()); } switch (x.nextClean()) { - case 0: + case 0: + // array is unclosed. No ']' found, instead EOF + throw x.syntaxError("Expected a ',' or ']'"); + case ',': + nextChar = x.nextClean(); + if (nextChar == 0) { // array is unclosed. No ']' found, instead EOF throw x.syntaxError("Expected a ',' or ']'"); - case ',': - nextChar = x.nextClean(); - if (nextChar == 0) { - // array is unclosed. No ']' found, instead EOF - throw x.syntaxError("Expected a ',' or ']'"); - } - if (nextChar == ']') { - return; - } - x.back(); - break; - case ']': + } + if (nextChar == ']') { return; - default: - throw x.syntaxError("Expected a ',' or ']'"); + } + x.back(); + break; + case ']': + return; + default: + throw x.syntaxError("Expected a ',' or ']'"); } } }