mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-24 00:03:17 -05:00
fix(#887): regression parsing array with non-string and boolean values
This commit is contained in:
@@ -522,10 +522,10 @@ public class JSONTokener {
|
||||
}
|
||||
|
||||
if (strictMode) {
|
||||
boolean isBooleanOrNumeric = checkIfValueIsBooleanOrNumeric(string);
|
||||
Object stringToVal = JSONObject.stringToValue(string);
|
||||
|
||||
if (isBooleanOrNumeric) {
|
||||
return string;
|
||||
if (stringToVal instanceof Number || stringToVal instanceof Boolean) {
|
||||
return stringToVal;
|
||||
}
|
||||
|
||||
throw new JSONException(String.format("Value is not surrounded by quotes: %s", string));
|
||||
@@ -534,20 +534,6 @@ public class JSONTokener {
|
||||
return JSONObject.stringToValue(string);
|
||||
}
|
||||
|
||||
private boolean checkIfValueIsBooleanOrNumeric(Object valueToValidate) {
|
||||
String stringToValidate = valueToValidate.toString();
|
||||
if (stringToValidate.equals("true") || stringToValidate.equals("false")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
Double.parseDouble(stringToValidate);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip characters until the next character is the requested character.
|
||||
* If the requested character is not found, no characters are skipped.
|
||||
|
||||
Reference in New Issue
Block a user