Skip to content

Clarify what happens if an unknown Enum value gets deserialised #90

Open
@struberg

Description

@struberg

Assume you have a Java class which has an Enum.
What happens if a JSON input contains a value for that Enum which is not a valid Enum value?

The only useful sentence I could find in the spec is

Deserialization of a JSON value into an enum instance MUST be done 
by calling the enum’s valueOf(String) method.

And valueOf(String) throws an IllegalArgumentException. Is this what is intended? Means should we blow up in that case with a JsonbException?

The other option would be to set the field to null.

Metadata

Metadata

Assignees

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