-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
SnakeYAML LoaderOptions.setAllowDuplicateKeys(false) should fail on duplicate keys. #413
Comments
only the options supported by snakeyaml's ParserImpl are supported by jackson. allowDuplicateKeys is an option of the snakeyaml binder, not the parser, so it's not supported. imo the current behavior is reasonable. |
I find being able to fail on duplicate keys a feature I enable most of the time. Right now I'm setting a flag that is supported by the I understand that if you have implemented it in a way that cannot support this, but then I should get some kind of "unsupported feature" exception when I try to do this. Also is there an other way achieve the same effect (i.e. fail on duplicate keys)? |
Jackson actually does have Now, like @yawkat explained, the reason option does not work is because it controls part of SnakeYAML we do not use: Jackson YAML backend uses lower level stream API. But it would definitely be good if Jackson's I will file a separate issue in case anyone wanted to tackle this -- I'd be happy to help but may not have time to implement this myself. |
Errr. I may have to let my former self correct me... it looks like I may have implemented support in 2017. At least there is @nielsbasjes It might be as simple as just enabling |
Awesome! So I only have to set it up in a slightly different way. Question: If you want I can put up a merge request later this week that translates anyone using |
@cowtowncoder I think this can be made more usable with something as simple as this #415 |
Fixed via #415; will be in 2.15.0-rc3. |
When creating a YAMLFactory we can specify the SnakeYAML
LoaderOptions
.One of the settings in there is to make the load fail if a duplicate key is found in the parsed yaml.
This feature does not work when using Jackson.
To demonstrate (I'm donating these tests to your project) two ways of parsing the same document
The text was updated successfully, but these errors were encountered: