That's exactly why JSON doesn't have comments. Some implementers were putting parsing directives in comments. That risked destroying interoperability. Rather than changing the spec to require stripping out comments before parsing, Douglas Crockford just disallowed comments altogether.
There is a use case for reading comments (though it really needs to be optional) which is if your code is editing the JSON rather than just getting information for it.
Man, what was it? Backspace? Backslash? Some kind of html templating language I had the displeasure to work with in one of my first jobs that used magic comments. I remember my onboarding buddy telling me they didn't do anything, and then discovering that no, they in fact drove the layout of the entire page. He'd been with the company over a year, and wasn't an idiot. It just doesn't make any sense and he hadn't really checked.
It was I thought it started with a B and was a typographical symbol, but maybe I'm misremembering. Underscore? That was a thing for sure but I don't remember if it was the same thing.
Edit: Knockout, that was it. Had it confused with Underscore.js. Not sure why I thought it started with a B
Thanks for the link. 22:22 and "Norway problem" are hilarious. I guess I have an excuse now for aggressively quoting everything. Also jsonc looks like much, much better alternative for future projects.
we're talking in context of configuration files that humans read. And most of the problems in that site are avoided by just enclosing the values in quotes and doing logic in whatever uses the yaml. EDIT: Oh i guess the site itself says that too. But yeah it doesn't feel like such a big deal
View all comments
Show parent comment
91
u/tokalper 4d ago
No, precisely because i work with a large team. We work eith large json files for configurations and they need commenting, we all do this.