children: [
{
o kind: "t3"
data: { // ExampleNodeT3 class should be used for kind == t3
+ t3var1: "val1"
+ t3var2: true
}
}
{
o kind: "t4"
data: { // ExampleNodeT4 class should be used for kind == t4
+ t4var1: false
+ t4var2: 2346
}
}
] ... etc.
@JsonTypeInfo(use=Id.NAME, property="kind")
@JsonSubTypes({
@Type(value=ExampleNodeT3.class, name="t3"),
@Type(value=ExampleNodeT4.class, name="t4")})
public abstract class ExampleNode {
...
public void setData(ExampleNode data) {
this.data = data;
}
When attempting to deserialize this with Jackson, the JsonTypeInfo hints fail when ExampleNode data is created because the "kind" property is associated with its parent and not visible. I have tried various variations of factory methods, and Jackson annotations, but because Jackson creates the ExampleNode object and passes it to setData() itself, I see no place to control what class of object is created.