Skip to content

Make trailing comma syntax errors more clear #141

Open
@dsnet

Description

@dsnet
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions