Jackson 库忽略属性

发布于 2024-12-12 02:56:29 字数 655 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人迟暮 2024-12-19 02:56:29

我也遇到了延迟加载问题,因为杰克逊试图序列化被忽略的字段。我找到了一篇文章相关使用 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.

吃→可爱长大的 2024-12-19 02:56:29

使用 Jackson 2.4 版本,效果完美。

您可以这样实现:

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties({"id"})

在此 developerWork 帖子 我找到了一个实现 Jackson v2.4 的示例,所有代码和库都可用。

Use Jackson version 2.4 it works perfectly.

This is how you can implemented:

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties({"id"})

In this developerWork post I found an example to implement Jackson v2.4 all the code and library is available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文