jakartaee / jakartaee/jsonb-api
Clarify what happens if an unknown Enum value gets deserialised
Open
documentation
enhancement
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
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`.
Contributor guide
Assessment
This issue has not been assessed yet.