jakartaee / jakartaee/jsonb-api
Handling of JSON input `null` is unspecified
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
Behavior of passing input `"null"` in `Jsonb.fromJson("null", T)` is unspecified.
Section 3.6 defines to return (type) `null` for unspecified output type, but this is only very limited case.
I propose following behavior:
Add section 3.14.3 "Null input", which reapplies the requirement for java fields to top level deserialization:
"The deserialization operation of JSON document consisting solely of null value results in null Java value. The exception are target types java.util.Optional, OptionalInt, OptionalLong, OptionalDouble. In this case the result is empty optional value. "
To make serialization and deserialization symmetrical, the change should affect serialization of top level empty optional as well. In section 3.4.3, "Empty optional instances are serialized as null. ". This is extension of current wording that only covers array items.
Contributor guide
Research direction
Review the proposed additions to sections 3.14.3 and 3.4.3 in the JSON-B specification, along with the existing wording in section 3.6. Check how top-level null values and empty Optional types are currently specified; done means resolving the behavior for deserialization and serialization consistently, including OptionalInt, OptionalLong, and OptionalDouble.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100