gpt4 book ai didi

java - JsonManagedReference 与 JsonBackReference

转载 作者:IT老高 更新时间:2023-10-28 21:05:32 27 4
gpt4 key购买 nike

我想知道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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com