Jackson 库忽略属性
Jackson @JsonIgnoreProperties 不忽略 possibleTargets ,但忽略所有者和 lemf 。我如何忽略列表。
@JsonIgnoreProperties( {"owner","lemf"," possibleTargets"} )
@Entity
public class Warrant extends Nameable {
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy ="warrant",targetEntity = com.endersys.lims.model.Target.class)
private List<Target> possibleTargets;
输出:
[{"status":"SCHEDULED","startDate":1320962400000,"endDate":1320962400000,"caseId":"1","possibleTargets":[],"name":"warrant_1","description":"decription","identity":"warrant_1","version":1,"systemId":1,"active":true}]
Jackson @JsonIgnoreProperties not ignoring possibleTargets ,but ignoring owner and lemf .How i can ignore lists.
@JsonIgnoreProperties( {"owner","lemf"," possibleTargets"} )
@Entity
public class Warrant extends Nameable {
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy ="warrant",targetEntity = com.endersys.lims.model.Target.class)
private List<Target> possibleTargets;
Output:
[{"status":"SCHEDULED","startDate":1320962400000,"endDate":1320962400000,"caseId":"1","possibleTargets":[],"name":"warrant_1","description":"decription","identity":"warrant_1","version":1,"systemId":1,"active":true}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了延迟加载问题,因为杰克逊试图序列化被忽略的字段。我找到了一篇文章相关使用 Jackson 1.9 问题已解决,我使用 @JsonIgnore 但 @JsonIgnoreProperties 仍然无法处理 onetomany 关系。
I was also have problem lazyload because jackson was trying to serialize ignored fields.I have find a post related to this.Using jackson 1.9 problem solved ,I use @JsonIgnore but @JsonIgnoreProperties still not working on onetomany relations.
使用 Jackson 2.4 版本,效果完美。
您可以这样实现:
在此 developerWork 帖子 我找到了一个实现 Jackson v2.4 的示例,所有代码和库都可用。
Use Jackson version 2.4 it works perfectly.
This is how you can implemented:
In this developerWork post I found an example to implement Jackson v2.4 all the code and library is available.