I'm using RESTeasy to convert a json from the payload to a POJO in the web server. I encounter a problem when one of those POJO member is generic.
For example:
public class MainPOJO { private MyParentClass c; [...] } public class MyParentClass { [...] } public class MyFirstChildClass extends MyParentClass { private int number; [...] } public class MySecondChildClass extends MyParentClass { private boolean isTrue; [...] } In the request payload (PUT) made by the client, you can found something like this json (notice that I send a MyFirstChildClass equivalent in json format in the "c" attribute):
{ c: {number:10} } Is there any way to tell RESTeasy that the property "c" in the MainPOJO can be either an instance of MyParentClass, MyFirstChildClass or MySecondChildClass?
Currently, it just try to instanciate a MyParentClass new instance but throw an error saying that property, for exemple, "number" is not mark as ignorable. But I wish it could be more intelligent and instantiate an object from the right class in the tree according to the properties in the json.
Is it possible?
Thanks!