Skip to content

Add DeserializationFeature.USE_NULL_FOR_MISSING_REFERENCE_VALUES for selecting null vs "empty/absent" value when deserializing missing Optional value #5350

@cowtowncoder

Description

@cowtowncoder

(note: follow-up to #3601, #5335)

As of 3.0.1, handling of "reference types" (java.util.concurrent.atomic.AtomicReference, java.util.Optional) is inconsistent: in case of "missing" (absent) value from incoming JSON, when passed via Constructor:

  1. AtomicReference is mapped to null (same as in 2.x and 3.0.0)
  2. Optional is mapped to Optional.empty() (same as in 2.x stand-alone module default)

but neither behavior is configurable. (also note that this mapping only matters for Creator-passed properties, including Records -- for Field/Setter settable, absent/missing value is never set).

Let's add a new DeserializationFeature to allow configuring this behavior.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions