Reputation: 3221
What is the way to consume a list of custom objects inside another custom object in JAX-RS CXF implementation? As an example my object looks like below
@POST
@Produces({MediaType.APPLICATION_JSON})
@Path("test")
public Response myMethod(MyCustomObject myCustomObject) {
Inside MyCustomObject it has a list of another custom object which reside inside this as an inner class
public class MyCustomObject {
private List<MyInner> innerObjects;
public class MyInner {
private String property;
....
}
....
}
Request JSON object is passed as the POST body of the request. When I debug this I could get the MyCustomObject passed properly while I am sending the innerObjects list as null. But it seems its not picking this correctly when I have this array based structure there with a custom object. Additionally instead of this custom object array when I have a primitive type or a string based array the service works fine. How to deal with the above scenario.
Upvotes: 0
Views: 899
Reputation: 421
It is probably because of the inner class.
Not sure what mapper you use (cxf default is jettison but it is all configurable), but the case is probably similar.
non-static inner classes (including anonymous ones) have set of hidden variables added by compiler, passed via (hidden) constructor. And as a consequence, do not have zero-argument ("default") constructor
Upvotes: 1