mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-02 19:15:27 -04:00
Simplify the check for object keys that are themselves objects.
For object keys, we can just skip the part of `nextValue()` that parses values that are objects or arrays. Then the existing logic for unquoted values will already stop at `{` or `[`, and that will produce a `Missing value` exception.
This commit is contained in:
parent
661114c50d
commit
16967f322e
@ -428,10 +428,6 @@ public class JSONTokener {
|
||||
case '"':
|
||||
case '\'':
|
||||
return this.nextString(c);
|
||||
case '{':
|
||||
throw syntaxError("Nested object not expected here.");
|
||||
case '[':
|
||||
throw syntaxError("Nested array not expected here.");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2230,7 +2230,7 @@ public class JSONObjectTest {
|
||||
assertNull("Expected an exception",new JSONObject(str));
|
||||
} catch (JSONException e) {
|
||||
assertEquals("Expecting an exception message",
|
||||
"Nested object not expected here. at 2 [character 3 line 1]",
|
||||
"Missing value at 1 [character 2 line 1]",
|
||||
e.getMessage());
|
||||
}
|
||||
try {
|
||||
@ -2239,7 +2239,7 @@ public class JSONObjectTest {
|
||||
assertNull("Expected an exception",new JSONObject(str));
|
||||
} catch (JSONException e) {
|
||||
assertEquals("Expecting an exception message",
|
||||
"Nested array not expected here. at 10 [character 11 line 1]",
|
||||
"Missing value at 9 [character 10 line 1]",
|
||||
e.getMessage());
|
||||
}
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user