Skip to content
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 comments in global.json #254

Closed
dorssel opened this issue Dec 4, 2021 · 3 comments
Closed

Allow comments in global.json #254

dorssel opened this issue Dec 4, 2021 · 3 comments
Labels
feature request New feature or request to improve the current logic

Comments

@dorssel
Copy link

dorssel commented Dec 4, 2021

Description:
Strip c-style comments from global.json before parsing.
I recommend https://www.npmjs.com/package/strip-json-comments, which helps keeping positional error reporting accurate.

Justification:
dotnet itself allows comments in global.json, so when I wanted to setup this action for an existing project it failed without modifying global.json. As an alternative, I had to use with: dotnet-version, which goes against the 'single source of truth' principle.

This is not to start a flame war; I am well aware that the standard JSON does not allow comments. And for data-interchange I agree. But for configuration it is actually quite handy. JSON5 allows it, and so does tsconfig.json (this very project is TypeScript).

Are you willing to submit a PR?
Sure.

@dorssel dorssel added feature request New feature or request to improve the current logic needs triage labels Dec 4, 2021
@xt0rted
Copy link

xt0rted commented Dec 7, 2021

https://github.com/json5/json5 supports this and should be a drop in replacement for the built-in JSON object.

@dorssel
Copy link
Author

dorssel commented Dec 8, 2021

@xt0rted
I am a bit reluctant to simply replace the entire JSON library. It should work, but JSON5 does a lot more than just allow comments.

Instead, I implemented #257, which is really a one-liner doing exactly as the proposal requested: remove comments before parsing global.json. Nothing more than that.

@dorssel
Copy link
Author

dorssel commented May 11, 2022

Abandoned #257. See comments there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

No branches or pull requests

4 participants
@xt0rted @vsafonkin @dorssel and others