Hi

{"name":"James", "activeDate":"<some datestring>", "age":30}
>
> I would expect the following to work
>
> @XmlRootElement
> public class Employee{
>  private String name;
>  private Date activeDate;
>  private int age;
>
>  // -- Setters and Getters omitted
> }
>
> However it fails because it wants a json packet that looks like this
> instead (using the classname)
> {"employee":{"name":"James", "activeDate":"<some datestring>", "age":30}}
>
>
In case of CXF, if the default Jettison-based  JSONProvider is used, then
you have this option :

http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-WrappingandUnwrappingJSONsequences

It involves explicitly configuring JSONProvider and setting a 'wrapperName'
property to 'employee'.

This option :

http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CustomizingJAXBXMLandJSONinputandoutput

is a bit more  involved but probably won't be needed in this case, unless
the rootless sequence has to be injected into a particular bean field...

Cheers, Sergey


> Thanks,
> James
>

Reply via email to