According to the yaml spec, duplicates should be treated as errors. But even in the latest
version of YAML-LibYAML(0.38) there is no error for duplicate keys.
example:
Following is the content of an .yaml file:
student :
- name : Tommy
mobile : 04567890
age : 19 # (in years)
contacts :
- type : email
name : tommy@yahoo.com
student :
- name : Fommy
mobile : 13456890
age : 20 # (in years)
contacts :
- type : email
name : fommy@outlook.com
Now if the content of the above file is loaded using the function 'load', then only last section
is coming. Each one is being overwritten by its successor section. So after 'load' we are
getting only following:
student :
- name : Fommy
mobile : 13456890
age : 20 # (in years)
contacts :
- type : email
name : fommy@yahoo.com
But we should get an error here because of the duplicate key ('student').
According to the yaml spec, duplicates should be treated as errors. But even in the latest version of YAML-LibYAML(0.38) there is no error for duplicate keys.
example:
Following is the content of an .yaml file:
Now if the content of the above file is loaded using the function 'load', then only last section is coming. Each one is being overwritten by its successor section. So after 'load' we are getting only following:
But we should get an error here because of the duplicate key ('student').