JAX-RS - remove the object name (RootElement) in the json of a request POST
<p>I use JAX-RS for RESTful services and when a client (angularjs, soapui, etc) makes a request POST, needs to add the object name (root element) in the json. For example:</p>

<pre><code>@POST
@Path("/create")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createUser (UserVo userVo){
    ...
    ...
}
</code></pre>

<p>--</p>

<pre><code>@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class UserVo implements Serializable, Comparable&lt;UserVo&gt;{
    ...
    ...
}
</code></pre>

<p>Request POST:</p>

<pre><code>{
    userVo:{
        email:"john@gmail.com",
        mobilePhone:1234456
    }
}
</code></pre>

<p>The clients need to specify "userVo" (if I remove <code>@XmlRootElement</code> from <code>UserVo</code>, not recognize the object), but I don´t want to specify it to improve my REST Api:</p>

<pre><code>{
    email:"john@gmail.com",
    mobilePhone:1234456
}
</code></pre>

<p>If don´t specify the object name, returns an error:</p>

<blockquote>
  <p>16:04:04,278  WARN [http-bio-8080-exec-3] AbstractJAXBProvider:660 -
  javax.xml.bind.UnmarshalException
   - with linked exception: [com.sun.istack.SAXParseException2; columnNumber: 0; elemento inesperado (URI:"", local:"email"). Los
  elementos esperados son &lt;{}userVo>]</p>
</blockquote>

<p>The only way I have found, is receiving a hashmap (clients send a "<code>APPLICATION_FORM_URLENCODED</code>" type) and build the object but I think that it is less efficient.</p>

<p>Any idea with JAX-RS? Is it possible?</p>

<p>For the response I use Gson and returns the object to the way I want:</p>

<pre><code>json = gson.toJson(userVo);
return Response.ok(json, MediaType.APPLICATION_JSON).build();
</code></pre>

<p>--</p>

<pre><code>{
    email:"john@gmail.com",
    mobilePhone:1234456
}
</code></pre>