3 ms·
Ack! You're right, but why is this the case? JavaScript obviously has comments, so someone must have made the decision to deliberately leave them out. What p
by amalcon 15y ago
Ack! You're right, but why is this the case? JavaScript obviously has comments, so someone must have made the decision to deliberately leave them out.
What possible reason could there be for that?
- FooBarWidget 15y agoJSON is meant to be a serialization language, not a config file language. Therefore it strips out all the things that it doesn't need. If you want a config file language then use YAML which is a much better candidate.
- amalcon 15y agoYes, YAML is very nice. Importantly, it reduces to key:value for the 90% of config files that don't require any hierarchy while still allowing hierarchy if you need it. I'm not sure I buy the serialization argument, though: it's a human-readable serialization format. One of the big advantages of human-readable formats is that you can craft data objects by hand (for automated tests, initial bootstrapping, etc). Comments are very helpful for those situations.
- JonnieCache 15y agoIt also has inheritance-like features that make it really suited to config files. JSON really isn't a good idea for config files when we have YAML.