title: jersey - How to use a Resource Method with multiple @FormParam of custom type
body: <p>I use jersey and have a method in my Resource class which has multiple parameters. These parameters are filled using <code>@FormParam</code> but the problem is, the type of the parameters are custom java types, not some primitives or <code>String</code>. I want to convert the value of parameters from <code>json</code> to custom java types. If I use <code>@Cosume(MediaType.APPLICATION_JSON)</code>, then I cannot use multiple parameters and if I remove it, parameters cannot be converted from json to their java instances.</p>
  
  <pre class="lang-java prettyprint-override"><code>@POST @Path("/add")
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.APPLICATION_JSON)
  public String add(@FormParam("source") BookEntity source, @FormParam("author") AuthorEntity a) throws JsonGenerationException, JsonMappingException, IOException, TransformationException
  {
          ...
  }
  </code></pre>
  
  <p>If I change the parameter types to <code>String</code> and then use Jackson deserialization, I can deserialize json parameters to java instances but I want to do it for other methods too and get it done automatically.</p>
  
  <p>I tried to use the approach used in <a href="https://jersey.java.net/nonav/documentation/latest/jaxrs-resources.html#d0e1399" rel="nofollow">Custom Java type for consuming request parameters</a> but I cannot make it work.</p>