title: Jersey: Consume all POST data into one object
body: <p>I am using Jersey 1.8 in my application. I am trying to consume <code>POST</code> data at the server. The data is of the type <code>application/x-www-form-urlencoded</code>. <strong>Is there a method to get all the data in one object, maybe a <code>Map&lt;String, Object&gt;</code>.</strong> </p>
  
  <p>I ran into Jersey's <code>@Consumes(MediaType.APPLICATION_FORM_URLENCODED)</code>. But using this would require me to use <code>@FormParam</code>, which can be tedious if the number of parameters are huge. Or maybe one way is this:</p>
  
  <pre><code>    @POST
      @Path("/urienodedeample")
      @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
      @Produces(MediaType.APPLICATION_JSON)
      public Response uriEncodedExample(String uriInfo){
          logger.info(uriInfo);
          //process data
          return Response.status(200).build();
      }
  </code></pre>
  
  <p>The above code consumes and presents the form data in a <code>String</code> object. </p>
  
  <pre><code>_search=false&amp;nd=1373722302667&amp;rows=10&amp;page=1&amp;sidx=email&amp;sord=desc
  </code></pre>
  
  <p>Processing this can be error prone as any misplaced <code>&amp;</code> and split() will return corrupt data. </p>
  
  <p>I used UriInfo for most of my work which would give me the query parameters in a <code>MultiValuedMap</code> or for other POST requests, sent the payload in <code>json</code> format which would in turn be unmarshalled into a <code>Map&lt;String, Object&gt;</code>. Any suggestions on how I can do the same if the POST data is of the type <code>application/x-www-form-urlencoded</code>. </p>