jsoncomment is good, but inline comment is not supported.
Check out jstyleson, which support
- inline comment
- single-line comment
- multi-line comment
- trailing comma.
Comments are NOT preserved. jstyleson
first removes all comments and trailing commas, then uses the standard json module. It seems like function arguments are forwarded and work as expected. It also exposes dispose
to return the cleaned string contents without parsing.
Example
Install
pip install jstyleson
Usage
import jstyleson
result_dict = jstyleson.loads(invalid_json_str) # OK
jstyleson.dumps(result_dict)