Jackson devuelve el resultado de la transformación de cuatro tipos de notas
paquete jar necesarios
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.9</version>
</dependency>
Si el proyecto se basa en springboot creado, sólo es necesario introducir
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Efectos específicos: a favor de la prueba efectiva
@JsonIgnore //忽略id不显示
private Integer id;
@JsonInclude(JsonInclude.Include.NON_NULL) //如果当前值为空不显示
private String name;
@JsonProperty("abc") // 相当于给phone 字段起别名
private String phone;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "zh",timezone = "GMT+8")//格式化日期
private Date createTime;