Debian Codegraph @

docs/src/why/duplicate-keys-disallowed.md

raw
1 ---
2 title: What is wrong with duplicate keys?
3 ---
4
5 Duplicate keys are allowed in regular YAML - as parsed by pyyaml, ruamel.yaml and poyo:
6
7 ```yaml
8 x: cow
9 y: dog
10 x: bull
11 ```
12
13 Not only is it unclear whether x should be "cow" or "bull" (the parser will decide 'bull', but did you know that?),
14 if there are 200 lines between x: cow and x: bull, a user might very likely change the *first* x and erroneously believe that the resulting value of x has been changed - when it hasn't.
15
16 In order to avoid all possible confusion, StrictYAML will simply refuse to parse this and will *only* accept associative arrays where all of the keys are unique. It will throw a DuplicateKeysDisallowed exception.