MyClass
must be configured to use Shape.OBJECT
in order for Jackson to:
- Use
ObjectSerializer
instead ofMapSerializer
- Invoke
MyClassBeanSerializerModifier.modifySerializer
objectMapper
.configOverride(MyClass.class)
.setFormat(JsonFormat.Value.forShape(Shape.OBJECT));
Register the serializer modifier:
SimpleModule m = new SimpleModule();
m.setSerializerModifier(new MyClassBeanSerializerModifier());
objectMapper.registerModule(m);