Objectmapper通过JsonIdentityInfo显示重复ID

我有两个相同属性的数据库响应。我的 ObjectMapper “忽略”第二个属性,因为在第一个属性上设置了相同的ID,但我想显示两个属性的完整信息。我猜有一个objectmapper功能,我可以在其中控制此行为,但找不到任何东西。也许有人可以帮助我。

我现在得到的是:

"attribut1": {
        "@id": 1,"id": 4711,"fullname": "Max Meier","email": "max.meier@gmx.com",},"attribut2": 1,

我想要拥有的东西:

 "attribute1": {
            "@id": 1,"attribute2": {
            "@id": 1,

ID由我设置

@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property = "@id",scope = Attribute.class)

我的ObjectMapper看起来像:

ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();

String entity = objectMapper.writeValueAsString(databaseResult);
zys2229888 回答:Objectmapper通过JsonIdentityInfo显示重复ID

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3118305.html

大家都在问