"name": null,
"username": null,
"parent_id": null,
"address": null,
"contacts": null,
"tel": null,
"company": "123",
"role_id": null,
"email": null,
"status": null,
"createTime": null,
"updateTime": null,
"lastLoginTime": null,
"markCode": null,
"labels_name": null,
"position_name": null,
"deviceStateCount": null,
ps:不用想map,就用bean 可以做到吗
可以使用注解@JsonInclude(Include.NON_EMPTY)
不过需要添加包
<!-- jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.3</version>
</dependency>
新加一个实体,暂时先只包含company、以后你想传其他的字段了再加,返回前端的时候,传这个实体就行了,就没有那么多null了
bean的话那只能新建bean返回了,bean里只包含你想要的字段
不用每个类上面设置的,可以设置一个全局的过滤器去过滤这些数据的com.fasterxml.jackson.annotation.JsonInclude.Include