5

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 */

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 :)

dave0688
  • 4,782
  • 6
  • 27
  • 59

2 Answers2

6

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

I solved it with adding the @JsonSerialize annotation:

@Transient
@JsonSerialize
private LoanRating loanRating;

Thanks all for your help :)

dave0688
  • 4,782
  • 6
  • 27
  • 59
2

You can simply define a getter with an JsonProperty annotation like this :

@JsonProperty("LoanRating")
public String getLoanRatingSer() {
    return this.loanRating;
}
jpmottin
  • 2,232
  • 26
  • 23