mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07: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
1 changed files with 2 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue