Skip to content

Handling of JSON input null is unspecified #129

Open
@pdudits

Description

@pdudits

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationInvolves the spec or javadocsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions