title: Jersey: hardcode POST/PUT ObjectMapper, without needing Content-Type header
body: <p>I have a Jersey 1.19.1 resource that implements a <code>@PUT</code> and <code>@POST</code> method. The  <code>@PUT</code> method expects a JSON string as the input/request body, while the <code>@POST</code> method accepts plain text.
  For the JSON mapping I am using Jackson 2.8.</p>
  
  <p>Since the resource is defined to work this way, I don't want the client to be required to specify a <code>Content-Type</code> request header, just because Jersey needs it to figure out which <code>ObjectMapper</code> to use on the request body.</p>
  
  <p>What I want instead, is to tell Jersey "Use this <code>ObjectMapper</code> for this <code>@PUT</code> input", or "Always assume this input will have an <code>application/json</code> <code>Content-Type</code> on this method."</p>
  
  <pre><code>@Produces(MediaType.APPLICATION_JSON)
  @Path("/some/endpoint/{id}")
  public class MyResource {
  
      @PUT
      public JsonResult put(
          @PathParam("id") String id,
          // this should always be deserialized by Jackson, regardless of the `Content-Type` request header.
          JsonInput input
      ) {
          log.trace("PUT {}, {}, {}", id, input.foo, input.bar);
          return new JsonResult("PUT result");
      }
  
      @POST
      public JsonResult post(
          @PathParam("id") String id,
          // this should always be treated as plain text, regardless of the `Content-Type` request header.
          String input
      ) {
          log.trace("POST {}, {}", id, input);
          return new JsonResult("POST result");
      }
  }
  </code></pre>
  
  <p>I only found <a href="https://stackoverflow.com/a/35823966/1296709">this answer</a>, but that's not what I'm looking for, as the solution there seems to be that the client should be required to add the correct <code>Content-Type</code> header, or otherwise do the object mapping manually.</p>