mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-05 20:35:37 -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");
|
throw x.syntaxError("Expected a ':' after a key");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace: this.putOnce(key, x.nextValue());
|
|
||||||
// Use syntaxError(..) to include error location
|
// Use syntaxError(..) to include error location
|
||||||
|
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
// Check if key exists
|
// Check if key exists
|
||||||
if (this.opt(key) != null) {
|
if (this.opt(key) != null) {
|
||||||
|
// back one token to point to the last key character
|
||||||
|
x.back();
|
||||||
throw x.syntaxError("Duplicate key \"" + key + "\"");
|
throw x.syntaxError("Duplicate key \"" + key + "\"");
|
||||||
}
|
}
|
||||||
// Only add value if non-null
|
// Only add value if non-null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user