Skip to content

Syntax error points to wrong position in json5 #47

Description

@plinnie

When there is an error in a json5 file, the error message seems to always point to the first element in the json5 file.

For example:

import json5
JSON5 = """
{  
    version: "1.0",
    author: "John Smith",
    people : [
        "Monty",
        "Python"foo
    ]    
}
"""
json5.loads(JSON5)

Gives the error:

Traceback (most recent call last):
  File "C:/Users/Admin/surfdrive/client/stuff/tests/testjson5.py", line 12, in <module>
    json5.loads(JSON5)
  File "C:\Users\Admin\Anaconda3\envs\python38\lib\site-packages\json5\lib.py", line 82, in loads
    raise ValueError(err)
ValueError: <string>:3 Unexpected "v" at column 5

I would expect the error: ValueError: <string>:7 Unexpected "f" at column 16.

json5 version: 0.9.6
OS: Windows 10
Python: 3.8.8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions