jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
4.91k stars 1.78k forks source link

Validate mapping key uniqueness #1221

Open brondani opened 10 months ago

brondani commented 10 months ago

According to YAML spec 1.2.2:

The content of a mapping node is an unordered set of key/value node pairs, with the restriction that each of the keys is unique.

The changes proposed here check the uniqueness of scalar mapping keys, throwing a NonUniqueMapKey exception when by inserting a new key/value pair an identical scalar key is already present in a mapping. Non identical but equivalent scalar content, for example “0o13” (octal) or “0xB” (hexadecimal), are not considered.

Address https://github.com/jbeder/yaml-cpp/issues/60.