Consider the following JSON object:
{
"selector": {
"id": "77112778040"
},
"data": {
"foo": "bar",
"_dmType": "http://www.example.com/foo/bar#SomeObject"
},
"_dmType": "http://www.example.com/something#OtherObject"
}
Examples of Java objects (skipped boilerplate code):
package com.example.something;
public class OtherObject {
private Selector selector;
private Object data;
}
package com.example.something;
public class Selector {
private String id;
}
package com.example.foo.bar;
public class SomeObject {
private String foo;
}
Of course I know how to map those _dmType values to proper java classes (thore are just namespaces and object type names from classes generated from xds files).
I tried with custom StdTypeResolverBuilder
and TypeIdResolverBase
. It adds custom property to all objects wchich is redundant - I want to add cutom type property only for root type and types wchich are extension of other types.
And What about deserialization? It works only when all objects in tree have _dmType. My classes do not have @JsonTypeInfo
annotation, I'm using JacksonAnnotationIntrospector
.