I am working with a simple Spring Boot based RestController. I am returning JSON, but I am unable to control the name of the keys generated in the response. The POJO looks like this:
public class SomePojo {
@JsonProperty("name")
private String fullName;
@JsonProperty("name")
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
}
If I create a new instance as follows:
SomePojo sm = new SomePojo();
sm.setFullName("John Doe");
and return the instance in the @ResponseBody. I expect to see
{ "name" : "John Doe" }
but I am seeing
{ "fullName" : "John Doe" }
I tried using the @JsonProperty("name")
annotation on both the property as well as its getter, but it is not working. Spring Boot version is 1.4.2. Any suggestions as to what I am missing?