Saying I have an interface A, I want to use custom deserializer for all classes implement interface A, So I use code below but it doesn\'t work, While CustomAserializer wo
Just in case someone need a solution to serialize and desiralize inheritance hierarchy
you can use jackson annotation in more elegant way : JsonTypeInfo and JsonSubTypes
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@Type(value = ServiceUser.class, name = "service"),
@Type(value = AdminUser.class, name = "admin")
})
public interface User{
// ...
}