参考: https://www.cnblogs.com/winner-0715/p/6109037.html
jackson的maven依赖
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency>
@JsonProperty 此注解用于属性上,作用是把该属性的名称序列化为另外一个名称,如把real_name属性序列化为name,@JsonProperty(value="name")。
import com.fasterxml.jackson.annotation.JsonProperty;
public class Student {
@JsonProperty(value = "real_name")
private String realName;
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
@Override
public String toString() {
return "Student{" +
"realName='" + realName + '\'' +
'}';
}
}