廣告

2016年3月17日 星期四

Usage of @JsonView (annotation of spring)


    public class View {
      interface Summary {}
      interface SummaryWithDetail extends Summary{}
    }
    -----------------------------------
    public class User { 
      @JsonView(View.Summary.class) 
      private Long id; 
      @JsonView(View.SummaryWithDetail.class) 
      private String firstname; 
    }
    -----------------------------------
    @RequestMapping("/user")
    @JsonView(View.Summary.class) 
    //or @JsonView(View.SummaryWithDetail.class) 
    public List getUsers(){
     return userService.listUsers();
    }
    -----------------------------------
    result of @JsonView(View.Summary.class)
    [
     {
        "id": 70,
     }
    ]
    
    result of @JsonView(View.SummaryWithDetail.class)
    [
     {
        "id": 70,
        "firstname": 222
     }
    ]

ref:
http://www.jianshu.com/p/633d83dd303b#

1 則留言:

  1. Harrah's Philadelphia Casino & Racetrack - Mapyro
    Find parking costs, opening 제천 출장샵 hours 남원 출장마사지 and 광양 출장샵 a parking map of Harrah's Philadelphia Casino & Racetrack 나주 출장안마 - Philadelphia, 이천 출장마사지 PA 3062547.

    回覆刪除