0
我有一个关于杰克逊反序列化问题,子类,比如我们有一个父类foo和子栏:杰克逊反序列化与可选参数
@JsonTypeInfo(use = JsonTypeInfo.Id.Name, include = JsonTypeInfo.As.PROPERTY,
property = "bar", visible = true)
@JsonSubTypes({
@Type(value = Foo.class, bar = ""),
@Type(value = Bar.class, bar = "true")
})
public class Foo{ String value; }
public class Bar extends Foo { boolean bar; }
子类来以JSON格式为:
{
"value": "this is some value for bar class",
"bar": "true"
}
但我需要杰克逊反序列化foo类,它应该通过该子类中的布尔值进行标识。因为请求可能会作为
{ "value": "this is some foo class value" }