jakartaee / jakartaee/jsonb-api

Clarify what happens if an unknown Enum value gets deserialised

Open
#90 8 comments 0 reactions 1 assignee Claimed by @struberg View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.