34 ms·
Instead of inventing "JSON with comments" format, why not simply use JSON5?
by codedokode 2y ago
Instead of inventing "JSON with comments" format, why not simply use JSON5?
- iddan 2y agoIt's already invented and JSON w Comments is a lot simpler than JSON5 to parse
- dathinab 2y agoBut if you already decide to forgo the benefits of JSON (mainly the ecosystem/wide spread support) and use a niche solution why would you go for JSON5? That looks like a worst of both world solution IMHO. You are probably better of with a TOML -> JSON mapping and would be better of with YAML too if YAML hadn't had really stupid ambiguity pitfalls.
- williamdclt 2y agoYou don't lose all benefits. Ecosystem often isn't a problem (I don't need high interop, I need this JSON5 file for one specific purpose), and you certainly don't lose all benefits: - JS syntax compatibility (low cognitive overhead) - Decent balance between machine-readable and human-readable - High familiarity for developers (if they know JSON, which they likely do, they can work with JSON5 with near-0 learning curve) Plus, JSON5 support is _somewhat_ widespread (maybe ~50% of tools I use support json5 for config?)
- chippiewill 2y agoI agree, it's better to just use JSON5. Having a mess where JSON parsers sometimes do, and sometimes don't allow comments is a bad outcome. JSON5 is advantageous because it's explicitly separate - it has a different file extension, it needs different libraries. Also it supports a few other utility features people want (like trailing commas) without bringing in the whole dangerous kitchen sink like YAML does.