title: Hot to make jackson to use snake_case / camelCase on demand in a Spring Boot REST API?
body: <p>I want to support both snake_case and camelCase in the json interface of my rest API.</p>
  
  <p>Jackson uses camelCase by default. I know there are many ways of making Jackson to use snake_case:</p>
  
  <p>Annotating properties individually: <code>@JsonProperty("first_name")</code></p>
  
  <p>Annotating classes with: <code>@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)</code></p>
  
  <p>Applying it to the whole application inside application.properties:
  <code>spring.jackson.property-naming-strategy=SNAKE_CASE</code></p>
  
  <p>But I haven't found information about how to allow the consumer to request the desired case. For example by using content negotiation (Accepts, Content-Type headers)</p>
  
  <p>Lets suppose we have the following example:</p>
  
  <pre><code>@RequestMapping("/my-resource") 
  public interface ApiController {
      @RequestMapping(method = RequestMethod.POST, produces = {"application/json"})
      MyResource createResource(@RequestBody MyResource myResource);
  
      @GetMapping(value="/{resourceId}", produces = {"application/json"})
      MyResource readResource(@PathVariable String resourceId);
  }
  </code></pre>
  
  <p>So one use case could be to use custom json media-type and provide content negotiation headers like:</p>
  
  <p><code>Accepts: application/vnd.snake+json</code></p>
  
  <p>and let the default <code>application/json</code> to use camelCase.</p>
  
  <p>But I cannot find the way of making jackson to use two different Mapper configurations based on the content negotiation.</p>