Skip to content

Add opt-in failure for duplicate elements when deserializing JSON arrays into Set types #6177

Description

@dpkass

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions