google / google/gson

Support for java.util.Optional

Open
#1,102 13 comments 22 reactions 0 assignees View on GitHub
enhancement java8
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

Usually, when I use Gson, I need to add special logic so that a field of `Optional` gets serialized as `X` if it's present, and gets omitted if it's empty; and conversely on deserialization. This seems like the only reasonable way to handle `Optional`. Would you consider offering this feature (or accepting a PR that implements it)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.