我想知道Jackson中@JsonManagedReference
和@JsonBackReference
的区别?
最佳答案
@JsonManagedReference is the forward part of reference – the one that gets serialized normally. @JsonBackReference is the back part of reference – it will be omitted from serialization.
所以他们真的取决于你们关系的方向
public class User {
public int id;
public String name;
@JsonBackReference
public List<Item> userItems;
}
public class Item {
public int id;
public String itemName;
@JsonManagedReference
public User owner;
}
关于java - JsonManagedReference 与 JsonBackReference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31319358/