json在将javapojo转换为json时反序列化动态顺序

nszi6y05  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(295)
public class X {
    Header property1;
    NeedHelp property2;
    Sections property3;
}

示例json

{
header: {
name: "Test",
description: "Description"
},
needHelp: {
deckNumber: "deck Number"
},
sections: 
{
media: {
type: "image"
}
}
}

应为json

{
header: {
name: "Test",
description: "Description"
},
needHelp: {
deckNumber: "deck Number"
},
sections: 
{
media: {
type: "image"
}
}

{
header: {
name: "Test",
description: "Description"
},
sections: 
{
media: {
type: "image"
}
},
needHelp: {
deckNumber: "deck Number"
}

{   
    needHelp: {
    deckNumber: "deck Number"
    },
    header: {
    name: "Test",
    description: "Description"
    },
    sections: 
    {
    media: {
    type: "image"
    }
    }
    }

实际响应

{
    header: {
    name: "Test",
    description: "Description"
    },
    needHelp: {
    deckNumber: "deck Number"
    },
    sections: 
    {
    media: {
    type: "image"
    }
    }
    }

我试着看看 @JsonPropertyOrder ,但这更多的是静态顺序。当我将这个pojo转换为json时,它应该保留属性顺序。。即一次我可以收到物业2,物业3,物业1,下次我回来物业1,物业2,物业3。
最终的json应该保留这个顺序。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题