4 ms·
>Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through J
by Zamicol 8y ago
>Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.
-Douglas Crockford, creator of JSON
There is no issue using JSON with comments for a config file.
- always_good 8y agoOr pipe through json5 which has other conveniences one might want like trailing commas.
- Zamicol 8y agoI love json5, but it's not always an option.
- always_good 8y agoYes, but ITT we're talking about someone apparently having the option to pick which format they're using for config, and they'd use JSON if it wasn't for one dealbreaker.
- ngrilly 8y agoYes, except for the fact that ECMAScript has a syntax for comments, but not JSON. Standards matter.
- artpepper2 8y agoBlurg, now every tooling pipeline that uses JSON needs to include a JSMin step...
- Zamicol 8y agoIf you're making comments for yourself in config files you control: /\/\/.*/gm https://regexr.com/3rbgb https://regexr.com/3rbgb
- lolc 8y ago"hello // syntax error"
- Zamicol 8y agoYou are 100% correct. For not single line comments, "//" in the datastructure, and everything else there are already well tested solutions for the problem. https://github.com/sindresorhus/strip-json-comments https://github.com/sindresorhus/strip-json-comments My point is only that this isn't a big issue. I don't understand why so many see it as a large issue. Instead, projects use non-standard YAML or other problematic solutions only because "JSON doesn't have comments".
- deleted 8y ago[deleted]