JSON:@Transient字段未序列化 [英] JSON: @Transient field not seralizing

查看:1154
本文介绍了JSON:@Transient字段未序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个域类Loan.java,其中的字段没有保留:

I have a domain class Loan.java with a field which is not persisted:

@JsonInclude()
@Transient
private LoanRating loanRating;

/* (Public) Getters and setters for that field are available as well */

但是,该字段没有被序列化-我在Frontend上看不到它.我正在与Jackson进行序列化.

However, the field does not get serialized - I don't see it on Frontend. I'm doing the serialization with Jackson.

有什么想法我在做什么错吗?

Any ideas what I'm doing wrong?

如果您需要更多信息,请告诉我,我会发布其他代码:)

If you need more information, please tell me and I'll post additional code :)

推荐答案

感谢您的回答! @Abdullah Khan的评论向我指出了正确的(并且可能是最简单的)解决方案.

Thanks for your answers! The comment of @Abdullah Khan pointed me to the correct (and probably easiest) solution.

我通过添加@JsonSerialize注释解决了它:

I solved it with adding the @JsonSerialize annotation:

@Transient
@JsonSerialize
private LoanRating loanRating;

非常感谢您的帮助:)

这篇关于JSON:@Transient字段未序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆