title: Change property names while deserialzing class to JSON in Spring MVC
body: <p>I'm trying to consume a rest API call using Spring as below:</p>
  
  <pre><code>HttpHeaders headers = new HttpHeaders();
  headers.add("Authorization", "Basic " + base64Creds);
  
  HttpEntity&lt;String&gt; request = new HttpEntity&lt;String&gt;(headers);
  RestTemplate restTemplate = new RestTemplate();
  
  Item item = restTemplate.exchange(url, HttpMethod.GET, request, Item.class).getBody();
  </code></pre>
  
  <p>The response I get from the API is in following form:</p>
  
  <pre><code>{    
  "item":[{
      "itemname": "abc",
      "qty":...
  }]
  }
  </code></pre>
  
  <p>The Item class has following fields:</p>
  
  <pre><code>Class Item{
      @JsonProperty("itemname")
      String name;
      @JsonProperty("qty")
      int quantity;
  
      // Getter / setter methods
  }
  </code></pre>
  
  <p>I've added JsonProperty annotations to the fields as their names are different from the json I get from the API. With this, I'm able to deserialize the api response successfully. </p>
  
  <p>However, when I try to serialize the Item class again as a json, the field names are "itemname" and "qty". Is there any way to keep these as "name" and "quantity", and yet be able to map to the API response?</p>
  
  <p>Thanks in advance.</p>