Update JSONTokener.java for #1007

fixed parse of `0.` in strict mode
This commit is contained in:
Michele Vivoda 2025-09-10 02:30:19 +02:00 committed by GitHub
parent 9b8eefc2de
commit 686c084897
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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