Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make trailing comma syntax errors more clear #141

Open
dsnet opened this issue Jan 22, 2025 · 0 comments
Open

Make trailing comma syntax errors more clear #141

dsnet opened this issue Jan 22, 2025 · 0 comments

Comments

@dsnet
Copy link
Collaborator

dsnet commented Jan 22, 2025

v := jsontext.Value(`["foo", "bar", "baz", ]`)
fmt.Println(v.Compact())

prints:

jsontext: invalid character ']' at start of value within "/3" after offset 22

We should instead report something like:

jsontext: invalid trailing ',' before ']' after offset 20

An accidental trailing comma is a common mistake in hand-modified JSON.
While the current syntactic error is correct (and actually the easiest to produce given the parsing context), it is not particularly easy for a human to diagnose the problem.

\cc @scottjab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant