restore-lenient-jsonarray initial commit

This commit is contained in:
Sean Leary
2026-06-15 16:43:46 -05:00
parent 33a4698428
commit c073157a61
2 changed files with 22 additions and 4 deletions
+4 -4
View File
@@ -131,9 +131,9 @@ public class JSONArray implements Iterable<Object> {
* @param x A JSONTokener instance from which the JSONArray is constructed.
* @param jsonParserConfiguration A JSONParserConfiguration instance that controls the behavior of the parser.
* @param isInitial Boolean indicating position of char
* @return
* @return true if a syntax error has occurred, otherwise false
*/
private static boolean checkForSyntaxError(JSONTokener x, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) {
private boolean checkForSyntaxError(JSONTokener x, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) {
char nextChar;
switch (x.nextClean()) {
case 0:
@@ -153,11 +153,11 @@ public class JSONArray implements Iterable<Object> {
return true;
}
if (nextChar == ',') {
// consecutive commas are not allowed in strict mode
// Consecutive commas are not allowed in strict mode.
// Otherwise, the tokener is backed up, and a null object is inserted by the calling code.
if (jsonParserConfiguration.isStrictMode()) {
throw x.syntaxError("Strict mode error: Expected a valid array element");
}
return true;
}
x.back();
break;