4 ms·
The nice thing about JSON5 is, you can move a project from a JSON-based config to JSON5-based config and get a significant improvement in human friendliness wit
by mort96 3y ago
The nice thing about JSON5 is, you can move a project from a JSON-based config to JSON5-based config and get a significant improvement in human friendliness without sacrificing backwards compatibility; yet it's a fairly well-documented and well-known format that's not as clinically insane as YAML. It's interesting to see how many people in that HN thread talks about JSON5 as if it's a data interchange format, complaining about things like comments and other features not needed for data interchange, when it's clearly meant to be a format for humans to read/write for things like configs (or they pretend all the problems with hand-editing JSON is trivially solved in the text editor).
I do have a few gripes though. I think allowing so many weird Unicode characters as whitespace was a bad choice. JSON5's reliance on Unicode character classes in general both makes it harder to write a parser and introduces compatibility concerns as different parsers will parse files differently based on which version of Unicode they use. But all in all, JSON5 is pretty nice.
In fact, I recently wrote my own parser for it: https://github.com/mortie/json5cpp https://github.com/mortie/json5cpp.
- Timon3 3y ago> The nice thing about JSON5 is, you can move a project from a JSON-based config to JSON5-based config and get a significant improvement in human friendliness without sacrificing backwards compatibility What backwards compatibility are you referring to? It seems like you actually are sacrificing BC, as the JSON5 file won't be readable by older versions of your software (that doesn't use a JSON5 parser yet).
- mort96 3y agoThat's forwards compatibility. Backwards compatibility: New versions of the software can use the files from old versions. Forwards compatibility: Old versions of the software can use the files from new versions. If you switch from JSON to JSON5, the new version can use the config file from an old version. If you switch from JSON to TOML, your users have to create a new config file, or you will have to support both JSON and TOML.
- idbehold 3y agoThe software maybe backwards compatible, but the format is not backwards compatible as old software (expecting JSON) cannot parse the JSON5 format.
- mort96 3y agoI'm not going to argue about that, since I never claimed that JSON5 is backwards compatible with JSON. I said software can move from JSON to JSON5 without breaking backwards compatibility. If you want to claim that JSON5 is forwards compatible but not backwards compatible with JSON, that's fine by me.
- Timon3 3y agoMakes sense, thank you!
- majkinetor 3y agoAmazingly nonsensical arguments against it on historic thread: that you should stringify object like its always an easy option, that comments shouldnt be used because of dsls like there is no even more stupid alternative, that it should not be changed because Daglas said so, and most fascinating, that one already has Yaml like its not 10000x times bigger language instead of 3 extra rules everybody actually wants. Amazed. Its really true that no progress is possible until current generation dies off :)