mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
fix(#871-strictMode): replaced stream with conventional loop for 1.6 compatibility
This commit is contained in:
@@ -457,7 +457,7 @@ public class JSONTokener {
|
||||
if (strictMode) {
|
||||
Object valueToValidate = nextSimpleValue(c, true);
|
||||
|
||||
boolean isNumeric = valueToValidate.toString().chars().allMatch( Character::isDigit );
|
||||
boolean isNumeric = checkIfValueIsNumeric(valueToValidate);
|
||||
|
||||
if (isNumeric) {
|
||||
return valueToValidate;
|
||||
@@ -475,6 +475,15 @@ public class JSONTokener {
|
||||
return nextSimpleValue(c);
|
||||
}
|
||||
|
||||
private boolean checkIfValueIsNumeric(Object valueToValidate) {
|
||||
for (char c : valueToValidate.toString().toCharArray()) {
|
||||
if (!Character.isDigit(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to get a JSONObject from the JSONTokener. The strictMode parameter controls the behavior of
|
||||
* the method when parsing the JSONObject.
|
||||
|
Reference in New Issue
Block a user