mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
chore(#871-strictMode): reverted refactor in JSONTokener
This commit is contained in:
parent
e2fe14d951
commit
f3b3491f4d
@ -542,6 +542,8 @@ public class JSONTokener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object nextSimpleValue(char c, boolean strictMode) {
|
Object nextSimpleValue(char c, boolean strictMode) {
|
||||||
|
String string;
|
||||||
|
|
||||||
if (c == '"' || c == '\'') {
|
if (c == '"' || c == '\'') {
|
||||||
String str = this.nextString(c);
|
String str = this.nextString(c);
|
||||||
if (strictMode) {
|
if (strictMode) {
|
||||||
@ -550,19 +552,6 @@ public class JSONTokener {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedUnquotedText(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses unquoted text from the JSON input. This could be the values true, false, or null, or it can be a number.
|
|
||||||
* Non-standard forms are also accepted. Characters are accumulated until the end of the text or a formatting
|
|
||||||
* character is reached.
|
|
||||||
*
|
|
||||||
* @param c The starting character.
|
|
||||||
* @return The parsed object.
|
|
||||||
* @throws JSONException If the parsed string is empty.
|
|
||||||
*/
|
|
||||||
private Object parsedUnquotedText(char c) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
@ -572,8 +561,8 @@ public class JSONTokener {
|
|||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
String string = sb.toString().trim();
|
string = sb.toString().trim();
|
||||||
if (string.isEmpty()) {
|
if ("".equals(string)) {
|
||||||
throw this.syntaxError("Missing value");
|
throw this.syntaxError("Missing value");
|
||||||
}
|
}
|
||||||
return JSONObject.stringToValue(string);
|
return JSONObject.stringToValue(string);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user