Reputation: 23
Wikipedia article https://en.wikipedia.org/wiki/YAML has "sequencer protocols for Laser eye surgery" example which first defines mapping with anchor label &id001 and then refers to the label but redefines one key:
- step: *id001
spotSize: 2mm # redefines just this key, refers rest from &id001
Is this a correct YAML document? Is it possible to override keys this way? This example fails in YAML parsers I could find online.
Upvotes: 0
Views: 220
Reputation: 31
You can use "merge" instead of override the key.
- step:
spotSize: 2mm
<< : *id001
In PyYAML
, yaml parser will ignore duplicate keys.
Upvotes: 1