4 ms·
it is an old song. JSON (as per spec) is a lightweight data-interchange format. YAML is a "human-friendly data serialization language for all programming lang
by nrvn 4y ago
it is an old song.
JSON (as per spec) is a lightweight data-interchange format.
YAML is a "human-friendly data serialization language for all programming languages" and by mere coincidence (it does not look to be by design until version 1.2.2 [0]) JSON is its subset and not vice versa!
And YAML is human-friendly in two ways:
- it is notoriously "human" in interpreting input, i.e. ignoring the context or misinterpreting others' words;
- it helps read serialized data via indentation-based syntax.
The biggest caveat is for whatever reason everyone ignores the key highlights of both JSON and YAML that are "data-interchange format" and "data serialization language". If I were to interpret these two terms I would rather say they both present great means for heterogenous programs to exchange data with YAML being a fancier brother better suited for human eyes. They were not meant to be used for configuration purposes or what not. But people started using them exactly for this purpose instead of creating a configuration format/language that would render into program-readable JSON(if needed).
CUE and Dhall are perhaps the first two attempts to create specifically a configuration language with the ability to serialize in yaml/json/etc.
I very much hope using YAML, JSON and even TOML for writing configurations will become an anti-pattern soon and will be replaced by something more suited for this role.
[0] https://yaml.org/spec/1.2.2/#12-yaml-history https://yaml.org/spec/1.2.2/#12-yaml-history