Skip to content
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

Add a DeserializationFeature for enabling exceptions for duplicate keys for JsonNode #237

Closed
cowtowncoder opened this issue Jun 6, 2013 · 1 comment

Comments

@cowtowncoder
Copy link
Member

Although it would be nice to have more general support for ensuring that incoming JSON has no duplicate keys, one thing that is much easier to do is to add such checks as part of Tree building.

That is: whenever using data-binding to read JSON trees (mapper.readTree(), or readValue(JsonNode.class)), it would be possible to throw a JsonMappingException if same key is seen second time. Check should be cheap as well; and we could then point to two-step conversion (JSON to tree, tree to POJO) as one way to validate that no duplicate keys are coming in.

For sake of completeness, here: FasterXML/jackson-core#60

is the related issue for doing the same at lower level, at JsonParser. The problem there is the additional cost of managing key sets; with tree model we have to keep track of that anyway.

@cowtowncoder
Copy link
Member Author

Forgot to mention name of the new feature: DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant