mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
Generalize the logic to disallow nested objects and arrays as keys in objects.
Fixes #771.
This commit is contained in:
@@ -402,12 +402,7 @@ public class JSONTokener {
|
||||
*/
|
||||
public Object nextValue() throws JSONException {
|
||||
char c = this.nextClean();
|
||||
String string;
|
||||
|
||||
switch (c) {
|
||||
case '"':
|
||||
case '\'':
|
||||
return this.nextString(c);
|
||||
case '{':
|
||||
this.back();
|
||||
try {
|
||||
@@ -423,6 +418,21 @@ public class JSONTokener {
|
||||
throw new JSONException("JSON Array or Object depth too large to process.", e);
|
||||
}
|
||||
}
|
||||
return nextSimpleValue(c);
|
||||
}
|
||||
|
||||
Object nextSimpleValue(char c) {
|
||||
String string;
|
||||
|
||||
switch (c) {
|
||||
case '"':
|
||||
case '\'':
|
||||
return this.nextString(c);
|
||||
case '{':
|
||||
throw syntaxError("Nested object not expected here.");
|
||||
case '[':
|
||||
throw syntaxError("Nested array not expected here.");
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle unquoted text. This could be the values true, false, or
|
||||
|
Reference in New Issue
Block a user