On Tue, Mar 15, 2011 at 7:53 PM, NBW <emailnbw_at_gmail.com> wrote:
> Hi Tatu -
> I'm using 1.5. So you are saying there should be no wrapping by default with
> POJO support? That's what I am seeing. So for example if I have:
Right, no wrapping with POJO support enabled.
> @XmlRootElement
> public class MyEntityDTO {
> private long id;
> private String computer;
> private long operation;
> private List<AnotherEntityDTO> moreDTOs;
> ...
> I get some JSON that looks like this:
> {"id":7,"operation":1,"computer":"AAA", "moreDTOs":[]}
Right, this is what Jackson data binding (POJO) produces and consumes
by default.
> as opposed to JSON that includes the wrapped XmlRootElement like so:
> {"myEntityDTO":{"id":7,"operation":1,"computer":"AAA", "moreDTOs":[]}}
> So I guess from the sound of it I can't have my cake (wrapping) and POJO
> support until 1.7. Is it possible to get wrapped empty arrays (like POJO
No, although constructing manual wrapper is obviously trivial, with class like
public class MyWrapper {
public MyEntityDTO myEntityDTO;
}
or with generic typing, just
public class MyWrapper<T> {
public T wrapper; // although name is then fixed as "wrapper", and
not based on type
}
> support is giving me with "moreDTOs":[] using JAXB natural or some other
> flavor that supports wrapping?
Maybe Jakub and others can answer this question, I don't know.
-+ Tatu +-