mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 03:15:32 -04:00
Adding JSONTokener.back() just before throwing JSONException
This forces JSONTokener.syntaxError(..) to point to the last character of the duplicate key.
This commit is contained in:
parent
7fed023080
commit
7d8353401a
@ -232,12 +232,13 @@ public class JSONObject {
|
||||
throw x.syntaxError("Expected a ':' after a key");
|
||||
}
|
||||
|
||||
// Replace: this.putOnce(key, x.nextValue());
|
||||
// Use syntaxError(..) to include error location
|
||||
|
||||
if (key != null) {
|
||||
// Check if key exists
|
||||
if (this.opt(key) != null) {
|
||||
// back one token to point to the last key character
|
||||
x.back();
|
||||
throw x.syntaxError("Duplicate key \"" + key + "\"");
|
||||
}
|
||||
// Only add value if non-null
|
||||
|
Loading…
x
Reference in New Issue
Block a user