mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
fix(#871-strictMode): replaced stream with conventional loop for 1.6 compatibility
This commit is contained in:
parent
0ff368ca07
commit
e2fe14d951
@ -396,7 +396,7 @@ public class JSONTokener {
|
|||||||
public String nextTo(String delimiters) throws JSONException {
|
public String nextTo(String delimiters) throws JSONException {
|
||||||
char c;
|
char c;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (;;) {
|
for (; ; ) {
|
||||||
c = this.next();
|
c = this.next();
|
||||||
if (delimiters.indexOf(c) >= 0 || c == 0 ||
|
if (delimiters.indexOf(c) >= 0 || c == 0 ||
|
||||||
c == '\n' || c == '\r') {
|
c == '\n' || c == '\r') {
|
||||||
@ -457,9 +457,9 @@ public class JSONTokener {
|
|||||||
if (strictMode) {
|
if (strictMode) {
|
||||||
Object valueToValidate = nextSimpleValue(c, true);
|
Object valueToValidate = nextSimpleValue(c, true);
|
||||||
|
|
||||||
boolean isNumeric = valueToValidate.toString().chars().allMatch( Character::isDigit );
|
boolean isNumeric = checkIfValueIsNumeric(valueToValidate);
|
||||||
|
|
||||||
if(isNumeric){
|
if (isNumeric) {
|
||||||
return valueToValidate;
|
return valueToValidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,6 +475,15 @@ public class JSONTokener {
|
|||||||
return nextSimpleValue(c);
|
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
|
* This method is used to get a JSONObject from the JSONTokener. The strictMode parameter controls the behavior of
|
||||||
* the method when parsing the JSONObject.
|
* the method when parsing the JSONObject.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user