I have an interface Event
and multiple enums that implement this interface (UserEvent
, BusinessEvent
, etc).
I want to deserialize the following json data:
{
"event" : "SIGNUP"
}
To this bean:
public class Input
{
private Event event;
public Event getEvent() {..}
public void setEvent(Event event) {..}
}
public enum UserEvent implements Event
{
SIGNUP;
}
Here, i'd like event to be deserialized to UserEvent.SIGNUP
.
How can I accomplish this? Reading up on @JsonTypeInfo
seems to indicate that an additional type
attribute would be needed, but in this case, there's just one string which maps directly to an enum value.