Hi folks, I'm Bertil, I'm new to this group. I approached this problem from a different angle.
I created a small facade library <https://github.com/bertilmuth/moonwlker> for Jackson that creates a specific builder for the different cases, like those: final ObjectMapper objectMapper = json().property("@class").toSubclassesOf(Base.class).mapper(); // these both work Foo foo1 = (Foo) objectMapper.readValue("{\"@class\": \"Foo\", \"value\": 11}", Base.class); Foo foo2 = objectMapper.readValue("{\"@class\": \"Foo\", \"value\": 12}" , Foo.class); // so do these Bar bar1 = (Bar) objectMapper.readValue("{\"@class\": \"Bar\", \"value\": 21}", Base.class); Bar bar2 = objectMapper.readValue("{\"@class\": \"Bar\", \"value\": 22}" , Bar.class); // so do these (could have used standard ObjectMapper as well) Foo foo3 = json().mapper().readValue("{\"value\": 13}", Foo.class); Bar bar3 = json().mapper().readValue("{\"value\": 23}", Bar.class); The classes themselvers are anootation free: public class Base { private int value; public int getValue() { return value; } public void setValue(int value) { this.value = value; } @Override public String toString() { return "Base [value=" + value + "]"; } } I'd be really interested in your thoughts and comments. -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/26d4d704-9185-4cfe-b1cc-d141e19c51aco%40googlegroups.com.
