mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
feat(#871-strictMode): enhanced and simplified strictMode logic
This commit is contained in:
@@ -225,14 +225,7 @@ public class JSONObject {
|
||||
case '}':
|
||||
return;
|
||||
default:
|
||||
String keyToValidate = getKeyToValidate(x, c, jsonParserConfiguration.isStrictMode());
|
||||
boolean keyHasQuotes = keyToValidate.startsWith("\"") && keyToValidate.endsWith("\"");
|
||||
|
||||
if (jsonParserConfiguration.isStrictMode() && !keyHasQuotes) {
|
||||
throw new JSONException("Key is not surrounded by quotes: " + keyToValidate);
|
||||
}
|
||||
|
||||
key = keyToValidate;
|
||||
key = x.nextSimpleValue(c, jsonParserConfiguration.isStrictMode()).toString();
|
||||
}
|
||||
|
||||
// The key is followed by ':'.
|
||||
@@ -285,11 +278,6 @@ public class JSONObject {
|
||||
}
|
||||
return x.nextValue();
|
||||
}
|
||||
|
||||
private String getKeyToValidate(JSONTokener x, char c, boolean strictMode) {
|
||||
return x.nextSimpleValue(c, strictMode).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONObject from a Map.
|
||||
*
|
||||
|
Reference in New Issue
Block a user