-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow optionally interpreting .json files as JSON5 #341
Comments
JSONC or JSON5 with a I'll note that inclusion of a JSON5 parser with This is achievable today if you pipe your files via stdin (so that their filenames are removed from the equation) and use
Before investing time and thought in something like failover parsing behaviors, does that usage suit your needs? Please let's refrain from getting into any OT disparagement of JSON or other specs. |
It's not just VSCode. It's any sort of config that you edit frequently, but VSCode is the most optimal example as it has a lot of As for the mentioned usage, not sure that'd be efficient with pre-commit, especially in a cross-system project. JSON was supposed to be data format normally, the other specifications extend it for usage like configs, where you like to comment stuff out, add comments for why things are configured like they are and have trailing commas for entries that get manually edited a lot. All of which don't matter for regular JSONs from e.g. web development that are mostly automatically generated. Thus IMO considering the config part, which I don't think is niche considering how big VSCode is alone, is or might be important sooner or later, assuming people that are setting such |
I'm circling back on this to make sure I post an update (before taking a short vacation, so I'll be out for a bit). I'm basically convinced that
I don't know exactly when I can get to this. I'd be open to and grateful for a PR but it will also be some time before I can review one. The interface will basically be a flag to turn this on. Some possible names to bat around:
|
another option: check-jsonschema --parse-as json5 ... fwiw, after reading this thread, i still think the optimal default behavior would be to attempt importing a JSON5 parser and if successful, default parsing mode on all JSON files to JSON5. |
As of now you get parse errors for common modern/human-readable JSON config usage - trailing commas, comments, etc. Changing extension of some of these files is impossible because they belong to external tools that expect
.json
, yet are able to parse/interpret it correctly as either JSON5 or JSONC. Examples: bunch of configs related to VSCode and its plugins.Overall JSON standards are a mess because the initial standard sucks and it's hard to have consensus now, but would be nice for tools like this to support as many valuable options as possible.
The text was updated successfully, but these errors were encountered: