JSON with Comments (jsonc) for Python
Maintained. Last release 3 months ago, commits in 7 of the last 26 weeks. Weaker on release cadence and contributor spread.
pip install json-with-commentsJSON with Comments for Python
Features
load(),loads()- Remove single line (
//) and block comments (/* */) - Remove trailing commas from arrays and objects
- Remove single line (
dump(),dumps()- Add comments
- Add trailing commas
Usage
pip install json-with-comments
>>> import jsonc
>>> jsonc.loads("{// comment \n}")
{}
>>> jsonc.loads("{/* comment */}")
{}
>>> jsonc.loads('{"spam": "ham // egg" /* comment */}')
{'spam': 'ham // egg'}
>>> jsonc.loads('{"spam": /* comment */"ham /* egg */"}')
{'spam': 'ham /* egg */'}
And just like json module