chore(#887): clean up parsedUnquotedText implementation

This commit is contained in:
rikkarth 2024-04-23 20:42:11 +01:00
parent 7cc19483fb
commit ce13ebd5fe
No known key found for this signature in database
GPG Key ID: 11E5F28B0AED6AC7

View File

@ -521,17 +521,17 @@ public class JSONTokener {
throw this.syntaxError("Missing value");
}
if (strictMode) {
Object stringToVal = JSONObject.stringToValue(string);
Object stringToValue = JSONObject.stringToValue(string);
if (stringToVal instanceof Number || stringToVal instanceof Boolean) {
return stringToVal;
}
return strictMode ? getValidNumberOrBooleanFromObject(stringToValue) : stringToValue;
}
throw new JSONException(String.format("Value is not surrounded by quotes: %s", string));
private Object getValidNumberOrBooleanFromObject(Object value) {
if (value instanceof Number || value instanceof Boolean) {
return value;
}
return JSONObject.stringToValue(string);
throw new JSONException(String.format("Value is not surrounded by quotes: %s", value));
}
/**