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 #58

Closed
iandunn opened this issue Jul 17, 2019 · 2 comments · Fixed by #81
Closed

Allow comments #58

iandunn opened this issue Jul 17, 2019 · 2 comments · Fixed by #81

Comments

@iandunn
Copy link

iandunn commented Jul 17, 2019

I'm not sure how closely you want to track zaach/jsonlint, but they have an open issue for this as well.


Comments aren't technically valid, but I wouldn't say they're invalid either.

Douglas Crockford (creator of JSON) has said:

A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments.

Comments were initially allowed in JSON, and were only removed to prevent people from adding parsing directives.

They're very useful in things like composer.json files, where there can sometimes be important things to document.

There's no reason that decoders can't allow and ignore them. Since some do just that, I think it makes sense for JSON linters to provide a flag that will let them pass through as well. The user will know best what their particular use case allows.

@Seldaek
Copy link
Owner

Seldaek commented Jul 29, 2019

I'm not strictly against supporting it here either as long as it's behind a feature flag.

@stof
Copy link
Contributor

stof commented Apr 30, 2020

Even allowing comments behind a flag won't allow you to put JS comments in the composer.json. For performance reasons, Composer uses PHP's json_decode to read JSON files. It uses this library only to provide a better error message in case of failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants