Canonical representation of a class object containing a list element in XML
- by dendini
I see that most implementations of JAX-RS represent a class object containing a list of elements as follows (assume a class House containing a list of People)
<houses>
<house>
<person>
<name>Adam</name>
</person>
<person>
<name>Blake</name>
</person>
</house>
<house>
</house>
</houses>
The result above is obtained for instance from Jersey 2 JAX-RS implementation,
notice Jersey creates a wrapper class "houses" around each house, however strangely it doesn't create a wrapper class around each person!
I don't feel this is a correct mapping of a list, in other words I'd feel more confortable with something like this:
<houses>
<house>
<persons>
<person>
<name>Adam</name>
</person>
<person>
<name>Blake</name>
</person>
</persons>
</house>
<house>
</house>
</houses>
Is there any document explaining how an object should be correctly mapped apart from any opninion?