linjackson78 / jstyleson

A python library to parse JSON with js-style comments.
MIT License
38 stars 4 forks source link

Warning: Use Json5 library instead #4

Closed Arcitec closed 2 years ago

Arcitec commented 3 years ago

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:

Here's the JSON5 spec: https://json5.org/

Arcitec commented 3 years ago

That JSON5 project is exactly what this library wants to be. It's a parser for JSON with JavaScript markup/features.

davystrong commented 3 years ago

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.