0

场景:我试图将现有 dto 的某些属性重用于我的 Restful 请求。

给定:com.fasterxml.jackson.annotation.*;//v2.9.0

我试图这样做:

class Parent {
 private String value;

 @JsonView(ChildView.Basic.class)
 private Child child;
}

class Child {
 @JsonView({ ChildView.Basic.class })
 private String basic;
 @JsonView({ ChildView.Full.class })
 private String full;

}

public class ChildView {
    public interface Basic {}
    public interface Full extends Basic {}
}

但是当我大摇大摆地访问时:

{
  "value": "",
  "child": {
     "basic": "",
     "full": ""
  }
}

代替

{
  "value": "",
  "child": {
     "basic": ""
  }
}

我做错了什么?

4

0 回答 0