jakartaee / jakartaee/jsonb-api
Serialization vs. deserialization of Optional types
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
Optional types has not compatible serialization and deserialization.
Deserialization:
- missing field - java field is null / unchanged,
- "null" - Optional.empty(),
- "any value" - deserialized to java field.
Serialization:
- null field - is not serialized / missing in json (except nilable),
- Optional.empty() - is not serialized / missing in json (except nilable),
- Optional.of("any value") - is serialized to "any value".
Problem is deserialization of null value. It is deserialized into Optional.empty(). But there is no way serialize it back to null value.
I propose serialize Optional.empty() into null value. This behavior is important for implementation of JSON Merge Patch - see https://tools.ietf.org/html/rfc7386 .
Contributor guide
Research direction
Start with the Optional serialization and deserialization cases described in this issue and compare them with RFC 7386, which the issue links for JSON Merge Patch semantics. The issue names no source files, tests, or entry points; done would mean deciding and covering how Optional.empty() is serialized relative to null and missing fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100