Closed Arcitec closed 2 years ago
That JSON5 project is exactly what this library wants to be. It's a parser for JSON with JavaScript markup/features.
The big issue with JSON5 is that it's not a drop in replacement. If I have opened a file as a String IO (i.e. with 'w' instead of 'wb'), it will raise an exception. Though jstyleson isn't perfect either since it doesn't expose the entire native json API.
I recommend everyone switch to a JSON5 library instead. JSON5 is JSON with JavaScript features/support. It's the most popular JSON language extension in the world. It has comments, support for trailing commas in objects/arrays, support for single-quoted keys/strings, support for unquoted object keys, etc. And there's proper parser libraries with deep test suites and everything working perfectly.
There are two different, high-quality Python implementations:
https://github.com/dpranke/pyjson5 (written entirely in Python, it's slow, has its own test suite, project started in 2015 and more "liked"). PyPi Page: https://pypi.org/project/json5/
Recommended: https://github.com/Kijewski/pyjson5 (uses compiled native code via Cython which is much faster, uses the official json5 js test suite instead of its own, project started in 2018). PyPi Page: https://pypi.org/project/pyjson5/
Here's the JSON5 spec: https://json5.org/