4 ms·
JSON is not optimized to be written by humans (I'd argue even JS is not well optimized for that </joke>). There are other formats for that, like YAML and TOML[
by cies 10y ago
JSON is not optimized to be written by humans (I'd argue even JS is not well optimized for that </joke>).
There are other formats for that, like YAML and TOML[1].
When JSON is needed for human-to-computer stuff, I'd say TOML is pretty much always a better choice. A common use case for TOML is config files. And I see a lot of config in JSON lately; this makes me sad. (Though not as sad as the config-in-XML thing the Java ecosystem suffered from.)
1: https://github.com/toml-lang/toml https://github.com/toml-lang/toml
- nerdponx 10y agoTOML is a good idea. Maybe it will catch on and sometime within this decade we will finally have a standard format for config file </wishfulthinking>
- crdoconnor 10y agoTOML is kinda ugly compared to YAML.
- ymse 10y agoYAML is a pain to parse. And as a human, having to remember quoting string values like "yes" and "on" to prevent them from being interpreted as booleans in YAML really grinds my gears. I don't care if it's prettier; YAML can't disappear quick enough. I wrote a haiku some years back to demonstrate how broken the Ruby implementation was. YAML: takes a no for a 'no': no spring,summer,fall,winter: 3,6,9,12 the game is: on Running it through ruby 2.3.1 yields.. {"YAML"=> {"takes a no for a 'no'"=>false, "spring,summer,fall,winter"=>36912, "the game is"=>true}}
- crdoconnor 10y agoI agree. That's partly why I wrote this: https://github.com/crdoconnor/strictyaml https://github.com/crdoconnor/strictyaml e.g. >>> load(x, Map({"YAML": MapPattern(Str(), Str())})) {'YAML': {'spring,summer,fall,winter': '3,6,9,12', "takes a no for a 'no'": 'no', 'the game is': 'on'}} >>> load(x, Map({"YAML": Map({"spring,summer,fall,winter": Str(), "takes a no for a 'no'": Bool(), "the game is": Bool()})})) {'YAML': {'spring,summer,fall,winter': '3,6,9,12', "takes a no for a 'no'": False, 'the game is': True}}
- pmlnr 10y agoThink of it as ini 2.0.
- DCoder 10y agoCounter-point: you can tell if the JSON you received is intact or was cut off, because it won't parse properly without the closing braces. You don't have that safety net with YAML or TOML.
- ymse 10y agoThat's a really good point. I opened an issue: https://github.com/toml-lang/toml/issues/429 https://github.com/toml-lang/toml/issues/429