【发布时间】:2019-02-18 04:37:05
【问题描述】:
我正在使用 Jackson + spring RestControlles
假设我有 3 节课
class Card {
String id;
String pan;
String holder;
String expiry;
}
class CardProfile {
String id;
Card card;
...
}
class Recipient {
String name;
Card card;
...
}
因此,当我序列化 CardProfile 对象时,我希望对象卡的所有字段在结果 json 中都是百分比。
但是在 Recipient object 的情况下,Json 必须只有 object card 的一部分(例如:pan, holder)。 有没有办法用不同的字段集在 json 中呈现 Card 对象?
使用 @JsonIgnore 之类的注解将从这两种情况中删除字段。
谢谢。
【问题讨论】:
标签: rest spring-boot jackson