第一种形式.java package com.cc.example.domain;import com.fasterxml.jackson.annotation.JsonView;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;/** * @author cc * @create 2017/10/16 11:20 **/@AllArgsC
package com.cc.example.domain; import com.fasterxml.jackson.annotation.JsonView; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; /** * @author cc * @create 2017/10/16 11:20 **/ @AllArgsConstructor @NoArgsConstructor @Data public class User { private int id; @JsonView({simpleView.class, detailView.class}) private String username; @JsonView({simpleView.class, detailView.class}) private String sex; @JsonView({detailView.class}) private String password; public interface simpleView {} public interface detailView {} }第二种形式.java
package com.cc.example.domain; import com.fasterxml.jackson.annotation.JsonView; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; /** * @author cc * @create 2017/10/16 11:20 **/ @AllArgsConstructor @NoArgsConstructor @Data public class User { private int id; @JsonView(simpleView.class) private String username; @JsonView(simpleView.class) private String sex; @JsonView(detailView.class) private String password; public interface simpleView {} public interface detailView extends simpleView {} }