ObjectMapper mapper = new ObjectMapper();
assertEquals("{\"@type\":\"TypeB\",\"b\":1}", mapper.writeValueAsString(bean));
// but we can override type name here too
mapper = new ObjectMapper();
mapper.registerSubtypes(new NamedType(SubB.class, "typeB"));
assertEquals("{\"@type\":\"typeB\",\"b\":1}", mapper.writeValueAsString(bean));
// and default name ought to be simple class name; with context
assertEquals("{\"@type\":\"TestSubtypes$SubD\",\"d\":0}", mapper.writeValueAsString(new SubD()));
}