I've seen some YAML files use the "merge" operator <<
. Here's an example from the "Yaml Cookbook" on yaml.org:
mapping:
name: Joe
job: Accountant
<<:
age: 38
On the other hand, I can't find any references to the merge operator in the specification docs on yaml.org.
Is this operator officially part of YAML, or is it just part of the Ruby implementation?
According to this SO answer:
Note that merge keys are not part of the YAML specification and therefore are not guaranteed to work. They are also specified for the obsolete YAML 1.1 version and have not been updated for the current YAML 1.2 version. We intend to explicitly remove merge keys in upcoming YAML 1.3 (and possibly provide a better alternative).
However, I can personally confirm that as of today (2023-10-27), the latest version of PyYAML (v6.0.1) still supports it, as does Docker Compose when parsing a docker-compose.yml
file.
Maybe their plans for YAML 1.3 fell through or are taking longer than anticipated, and in the meantime, everyone's enjoying the benefits of that very useful merge key too much to stop?