title: Using Spring @RequestBody to convert JSON with mixed convention in payload to Entity Object
body: <p>I am using Spring <code>@RequestBody</code> to map a JSON payload to a Java Object. Unfortunately this JSON payload does not use a set convention but rather has names that use both camelCase and snake_case.</p>
  
  <p>To be clear my <code>Controller</code> looks like this:</p>
  
  <pre><code>@RequestMapping(value="/mobile/device", method = RequestMethod.PUT)
  public ResponseEntity&lt;Object&gt; flagDevice (@RequestBody List&lt;MobileDeviceData&gt; deviceInfoList) {
      ... code here ...
  }
  </code></pre>
  
  <p>with the <code>MobileDeviceData</code> <code>Entity</code> object having several setter methods like:</p>
  
  <pre><code>public void setDeviceName(String deviceName) {
      this.deviceName = deviceName;
  }
  
  public void setFlagId(int flagId) {
      this.flagId = flagId;
  }
  </code></pre>
  
  <p>This works great and without any extra effort when the JSON objects name is camelCase. However for snake_case names I need to add the <code>Annotation</code>:</p>
  
  <pre><code>@JsonProperty("flag_id")
  private int flagId;
  </code></pre>
  
  <p>in order for it to be picked up. </p>
  
  <p>I know it's not a good idea to use the <code>@JsonProperty</code> if it can be avoided as you then will need to annotate every parameter. My question is, is there a more general way to enforce matching snake_case with the corresponding camelCase in the <code>Entity</code> object? And obviously to do it without screwing up the ones that are already camelCase.</p>