-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Load yaml file with duplicated keys #764
Comments
Can you provide a minimal example of code and yaml that throws the error? There was a pr that we merged in a little bit ago that would throw on duplicate keys, but that was an opt in feature where you had to explicitly enable it. |
Thanks for your reply! I met this problem when trying to load a Asset Prefab Yaml from a Unity project. It seems that Unity allows duplicated keys while Yaml standard syntax actually do not. I shorten the prefab yaml and attached it as a file. Here is the code I use: An Exception will be thrown when yaml.Load():
|
Thanks for the example. I’ll take a look at it when I get some time. Might be a couple of days. |
Thanks! |
Is this still a problem for you with the latest version? |
@EdwardCooke the |
Ok, I'll take a look when I get time. Work is brutal right now, so it may be a week or 2. I didn't think the yamlstream used a dictionary at all, thought it just dumped out the individual yamlnodes. I'll let you know what I find. |
Hello I also encountered the same problem, was there any solution found |
Can you post in a small snippet of code and yaml to reproduce the problem? |
Never mind. Just found it. I just need some more time to think about how to solve this without making a big impact. My initial idea is to add another property/argument on the YamlDtream class or Load method that allows duplicates. With that in place I can use a list in the YamlMappingNode instead of a dictionary, and if duplicate keys is not enabled, keep track of them and throw on duplicates if not enabled. The Children property would remain a dictionary but it would convert the list to that dictionary. I think it would work. I’ll see if I can find some time in the next day or 2. Pr’s are also welcome if you need it sooner. |
Thank you for response. I hope this answer will solve the problem |
I’ll be working on this and getting a fix out shortly. |
Hi, I found that the latest version 16.1.13 still throw exception if there is a duplicate key, can ignore the later duplicate key and don't throw exception? Or add a switch to indicate how to handle duplicate key? Throw exception or ignore the later one? |
Is there a way to load yaml files with duplicated keys without throwing any exception?
The text was updated successfully, but these errors were encountered: