4 ms·
> OTOH, generating YAML documents is easy. On the topic of syntax, I'll say YAML is not the best format for configuration either. At a glance, it looks simple
by sirn 9y ago
> OTOH, generating YAML documents is easy.
On the topic of syntax, I'll say YAML is not the best format for configuration either. At a glance, it looks simple and easy to write, but YAML can bite its user in an unexpected ways due to its implicit typing[1]. For example this YAML:
on: yes
…will be parsed to:
{true => true}
…which cannot be serialized to JSON in a lossless way (since JSON spec specify that a key must be a string):
{"true":true}
…and translating this back to YAML would result in:
'true': true
This is without considering other features such as anchor, aliases and tags[2], which further make the YAML spec incredibly complex.
[1]: https://github.com/crdoconnor/strictyaml/blob/master/FAQ.rst#what-is-wrong-with-implicit-typing https://github.com/crdoconnor/strictyaml/blob/master/FAQ.rst...
[2]: http://www.yaml.org/spec/1.2/spec.html http://www.yaml.org/spec/1.2/spec.html
- icebraining 9y agoI agree that the implicit typing is dangerous, but developers shouldn't expect to convert YAML to JSON losslessly. It's a superset, after all.
- nerdponx 9y agoMake isn't hierarchical and your build system probably doesn't need to be either. IMO ini/TOML format would be the way to go.