jackson的maven依赖
<dependency> ???<groupId>com.fasterxml.jackson.core</groupId> ???<artifactId>jackson-databind</artifactId> ???<version>2.5.3</version></dependency>
所以引入这一个依赖就可以了
@JsonProperty 此注解用于属性上,作用是把该属性的名称序列化为另外一个名称,
如把trueName属性序列化为name,@JsonProperty(value="name")。
import com.fasterxml.jackson.annotation.JsonProperty;public class Student { ???@JsonProperty(value = "real_name") ???private String realName;
这里需要注意的是将对象转换成json字符串使用的方法是fasterxml.jackson提供的!!而不是使用阿里巴巴
的fastjson来实现的。
@JsonProperty的使用
原文地址:https://www.cnblogs.com/feifeicui/p/8776273.html