FasterXML / FasterXML/jackson-databind
Add opt-in failure for duplicate elements when deserializing JSON arrays into Set types
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.5k
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 28
Description
### Is your feature request related to a problem? Please describe.
When Jackson deserializes a JSON array into a `Set`, elements considered duplicates by the target Set are silently discarded.
This is normal Set behavior, but it makes deserialization lossy and can hide invalid input. Applications with Set-valued request properties may want to reject duplicate array elements instead of silently canonicalizing them.
### Describe the solution you would like
Please consider adding an opt-in deserialization setting that fails when the target Set rejects an array element as a duplicate.
Existing behavior should remain the default for backward compatibility.
The setting could potentially be exposed globally through a `DeserializationFeature`, per property, or both. The resulting input-mapping error should include the duplicate element array index where possible.
### Usage example
The appropriate configuration API should be agreed with the maintainers first.
### Additional context
I observed this with Jackson Databind 2.19.2 and could not find an existing issue or pull request for opt-in duplicate rejection during Set deserialization.
I would be willing to contribute an implementation once the desired API and scope are agreed.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no implementation files or tests. First clarify the configuration API and scope with maintainers, then inspect existing Set deserialization and configuration entry points; done means duplicate elements can be rejected opt-in, default behavior remains unchanged, and the mapping error includes the duplicate array index where possible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, json
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100