-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow duplicate keys in yaml. #102
Comments
Maps by definition have unique keys. |
You want multiple values to use an ArrayList as the map value? You could use a Map implementation that does this. Or you could fork YamlBeans to do this. |
Yeah.. By default a hashmap ignores duplicate keys and overwrites the value with the latest one. But my requirement is to allow dupicate keys and append its values like a MultiValuedMap. Can YamlBeans do this? |
String yaml = "key: 001\nkey: 002";
YamlReader reader = new YamlReader(yaml);
Object object = reader.read(); object is a HashMap instance, does not support duplicate keys.
String yaml = "key: 001\nkey: 002";
YamlReader reader = new YamlReader(yaml);
ArrayListValuedHashMap<String, String> arrayListValuedHashMap =
reader.read(ArrayListValuedHashMap.class); Deserialization exception, yamlbeans does not support.
String yaml = "key: 001\nkey: 002";
YamlDocumentReader yamlDocumentReader = new YamlDocumentReader(yaml);
YamlDocument yamlDocument = yamlDocumentReader.read();
YamlEntry entry1 = yamlDocument.getEntry(0);
System.out.println("key: " + entry1.getKey() + ", value: " + entry1.getValue());
YamlEntry entry2 = yamlDocument.getEntry(1);
System.out.println("key: " + entry2.getKey() + ", value: " + entry2.getValue()); Console:
|
Can yamlreader append the values duplicate keys to the map instead of overwriting them?
The text was updated successfully, but these errors were encountered: