I have two classes
class A has
private B messageOwner;
class B has
@JsonIgnore
private List<A> messages = new ArrayList<>();
now when i want to send class A as json i want it to contain also informations about class B ( without list )
yet using this it omites class B completely. I tried using @JsonManagedReference, @JsonBackReference but the result was the same.
What is the right way to solve this circular reference?
@Transient
private B messageOwner;
This does for the JSON serialization what the transient
type modifier does for the normal serialization. If the JSON library supports it.
Of course the messageOwner
will be null after deserialisation.