use = JsonTypeInfo.Id.MINIMAL_CLASS option will serialize minimal relative package path. For example, for supertype "com.logicbig.example.Shape", and concrete type "com.logicbig.example.shapes.Circle", only ".shapes.Circle" would be included; for "com.logicbig.example.shapes.impl.Rectangle" only ".shapes.impl.Rectangle" for "com.logicbig.example.Square" only ".Square" will be included.

I can not understand how the option understands that the minimum relative path of the package is exactly that? In the example about Shape, why, for example, not .example.shapes.Circle , namely .shapes.Circle ? Regarding what is the path chosen?

    1 answer 1

    The minimum class path is selected by comparing two classes - the superclass and the subclass.

    In this example, the superclass is com.logicbig.example.Shape , a subclass of which is com.logicbig.example.shapes.Circle . They have a common path com.logicbig.example , which is deleted during serialization. Therefore, only Shape and .shapes.Circle .