oops forgot null

This commit is contained in:
marilynel
2025-07-13 12:52:42 -08:00
parent fdaeb486ed
commit c91b728386
2 changed files with 16 additions and 11 deletions

View File

@@ -513,18 +513,19 @@ public class JSONTokener {
Object obj = JSONObject.stringToValue(string);
// if obj is a boolean, look at string
if (jsonParserConfiguration != null &&
jsonParserConfiguration.isStrictMode() && obj instanceof Boolean) {
if (!"true".equals(string) && !"false".equals(string)) {
jsonParserConfiguration.isStrictMode()) {
if (obj instanceof Boolean && !"true".equals(string) && !"false".equals(string)) {
// Strict mode only allows lowercase true or false
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not lowercase boolean", obj));
}
}
// Strict mode only allows strings with explicit double quotes
if (jsonParserConfiguration != null &&
jsonParserConfiguration.isStrictMode() &&
obj instanceof String) {
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not surrounded by quotes", obj));
else if (obj == JSONObject.NULL && !"null".equals(string)) {
// Strint mode only allows lowercase null
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not lowercase null", obj));
}
else if (obj instanceof String) {
// Strict mode only allows strings with explicit double quotes
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not surrounded by quotes", obj));
}
}
return obj;
}