This commit is contained in:
marilynel 2025-09-21 16:37:20 -08:00
commit 05867c4b0b
2 changed files with 5 additions and 0 deletions

View File

@ -105,6 +105,8 @@ public class JSONArray implements Iterable<Object> {
if (nextChar == 0) { if (nextChar == 0) {
// array is unclosed. No ']' found, instead EOF // array is unclosed. No ']' found, instead EOF
throw x.syntaxError("Expected a ',' or ']'"); throw x.syntaxError("Expected a ',' or ']'");
} else if (nextChar==',' && jsonParserConfiguration.isStrictMode()) {
throw x.syntaxError("Array content starts with a ','");
} }
if (nextChar != ']') { if (nextChar != ']') {
x.back(); x.back();

View File

@ -509,6 +509,9 @@ public class JSONTokener {
string = sb.toString().trim(); string = sb.toString().trim();
if ("".equals(string)) { if ("".equals(string)) {
throw this.syntaxError("Missing value"); throw this.syntaxError("Missing value");
} else if (jsonParserConfiguration != null &&
jsonParserConfiguration.isStrictMode() && string.endsWith(".")) {
throw this.syntaxError(String.format("Strict mode error: Value '%s' ends with dot", string));
} }
Object obj = JSONObject.stringToValue(string); Object obj = JSONObject.stringToValue(string);
// if obj is a boolean, look at string // if obj is a boolean, look at string