vaidik / commentjson

Add JavaScript or Python style comments in JSON.
MIT License
104 stars 25 forks source link

commentjson raises the wrong error type on trailing comma #43

Closed EliRibble closed 4 years ago

EliRibble commented 4 years ago

For example, let's say commentjson is told to load the following:

{
  // there is a trailing comma below
  "c": 1,
}

This will be caught on commentjson.py:170 as a lark.exceptions.UnexpectedCharacters exception. That seems reasonable. Unfortunately, commentjson.py:205 will then catch this as a generic Exception and translate it into a JSONLibraryException(e). This is bad because it breaks API-compatibility with the Python json library, which would just raise a ValueError

vaidik commented 4 years ago

Not fixing this directly. Instead of that support for trailing commas is being added to expand use-cases for commentjson.