Have the following in YAML-
key1
key2: "value"
key1
key2
key3: "value2"
Get exception duplicate key key1. Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing MappingNode
Trying various combinations but unable to parse it correctly.
Could someone please help or guide here.
Thanks
Your YAML is syntactically invalid, but I am assuming it actually looks like this:
key1:
key2: "value"
key1:
key2:
key3: "value2"
Your error is that key1
is used two times as mapping key in the root node. This is illegal as per YAML spec:
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 solution is to make all keys of the same mapping unique:
key11:
key2: "value"
key12:
key2:
key3: "value2"