4 ms·
Yaml is in fact a superset of JSON. You can parse a json with yaml parser. You can also mix json and yaml in the same document and use [..., ..] for annotating
by sztanko 12y ago
Yaml is in fact a superset of JSON. You can parse a json with yaml parser. You can also mix json and yaml in the same document and use [..., ..] for annotating arrays and { "bar" : "foo"} for objects. Some yaml libraries allow you to generate yaml that has one style for top level and json style for nested elements / long arrays to improve readability.
However I have also learned the following:
- in python, parsing yaml file is hundred times slower than json (in fact, my benchmark was showing around 400x slowdown). Therefore you can't really use it in cases where performance matters at least a little bit. A yaml 1k line yaml can load more than half a second (yrmv)
- if your yaml doc is longer than two screens, it loses its readability benefits.
Therefore it is best to use a whole directory of yaml files, each describing a specific feature. E.g. Ansible is a good example of how to use yaml files.
- frik 12y ago> Ansible and YAML I am searching for an replacement of / alternative to Ansible written in Go or Rust that uses JSON or INI as config format. (Ansible is written in Python. Both Python and YAML rely on outline indentation which causes many headaches)