Skip to content

Fix Optional deserialization of null - #566

Merged
rbygrave merged 5 commits into
avaje:mainfrom
thatcomputerguy0101:optional-null
Aug 18, 2026
Merged

Fix Optional deserialization of null#566
rbygrave merged 5 commits into
avaje:mainfrom
thatcomputerguy0101:optional-null

Conversation

@thatcomputerguy0101

@thatcomputerguy0101 thatcomputerguy0101 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

If serializeNulls is set to true, an empty Optional would be serialized as JSON null, but deserialized as Java null instead of an empty Optional. While both Java null and empty Optional map onto JSON null, I think the vast majority of use cases would want to use an empty Optional over null. This changes the deserialization of Optionals to recognize null and return an empty Optional.

SentryMan
SentryMan previously approved these changes Aug 12, 2026
Comment thread jsonb/src/main/java/io/avaje/jsonb/core/OptionalAdapters.java Outdated
Comment thread jsonb/src/main/java/io/avaje/jsonb/core/OptionalAdapters.java Outdated
@SentryMan
SentryMan requested a review from rbygrave August 15, 2026 00:37
@SentryMan SentryMan added this to the 3.15 milestone Aug 15, 2026
@SentryMan

Copy link
Copy Markdown
Contributor

@rbygrave have you anything to add?

@rbygrave
rbygrave merged commit 80fd88e into avaje:main Aug 18, 2026
5 checks passed
@SentryMan

Copy link
Copy Markdown
Contributor

3.15-RC5

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

Successfully merging this pull request may close these issues.

3 participants