I have a case where my request body has an object which is backed by inheritance.
So when I use @RequestBody and do not explicitly specify the type of subclass it does not pick/determine that automatically.
Is there a way to do it without this ->
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = Fence.class, name = "fence"),
@JsonSubTypes.Type(value = Rectangle.class, name = "rectangle"),
@JsonSubTypes.Type(value = Point.class, name = "point"),
@JsonSubTypes.Type(value = Circle.class, name = "circle")
})
public class Element implements Serializable {
}
This has nothing to do with this library in particular or Problem+JSON in general.
You'd be better off asking this on stackoverflow.
Having said that:
Instead of enumerating all subtypes at this place, you can put [`@JsonTypeName`](https://javadoc.io/static/com.fasterxml.jackson.core/jackson-annotations/2.15.0/com/fasterxml/jackson/annotation/JsonTypeName.html) on each class individually. But then you'd need to register those classes explicitly using [`registerSubTypes`](https://javadoc.io/static/com.fasterxml.jackson.core/jackson-databind/2.15.0/com/fasterxml/jackson/databind/cfg/MapperBuilder.html#registerSubtypes-java.lang.Class...-). I don't believe you can get rid of `JsonTypeInfo` here, since it is the root object.
I have a case where my request body has an object which is backed by inheritance. So when I use @RequestBody and do not explicitly specify the type of subclass it does not pick/determine that automatically. Is there a way to do it without this ->