I have two entities:
Parent {
Child[] children;
}
and
Child {
Parent parent;
}
I'm aware about @JsonBackReference
and @JsonManagedReference
.
They are good, if I'm serializing instances of Parent
.
But I also need to transfer instances of Child
and I want to have the parent
field populated.
In other words:
- On serialization of
Parent
it should have children
but their parent field might be empty (can be solved by using json reference annotations).
- On serialization of
Child
it should have parent
with their children
(but children
don't have to have parent
populated.
Is there a way to solve it using standard Jackson capabilities?
I.e. skip serialization of entities which were already serialized instead of marking fields eligible or non-eligible for serialization.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…