fastjson 反序列化问题

6vl6ewon  于 2021-11-27  发布在  Java
关注(0)|答案(3)|浏览(421)

fastjson 带类型的json串
{ "@type": "com.ysxs.dmp.condition.AccessCondition", "child": null, "range": "EVERY_ONE", "labelId": "A01", "endValue": 3, "flowType": [ "_4G" ], "relation": "AND", "startValue": 1, "endCalculation": "LT", "startCalculation": "GT", "hour": [ 1, 2, 3, 4, 5 ], "sss": [ "23", "46" ] }

如果反序列化对象中存在父子关系,使用父类作为parser对象时 ,则序列化顺序导致数据丢失
{ "hour": [ 1, 2, 3, 4, 5 ], "@type": "com.ysxs.dmp.condition.AccessCondition", "child": null, "range": "EVERY_ONE", "labelId": "A01", "endValue": 3, "flowType": [ "_4G" ], "relation": "AND", "startValue": 1, "endCalculation": "LT", "startCalculation": "GT", "sss": [ "23", "46" ] }
该json丢失了hour,如果放到@type后,该数据则不会丢失

mefy6pfw

mefy6pfw1#

最新版本扔出现问题

4si2a6ki

4si2a6ki2#

@wenshao 大佬,帮忙看一下, 是我用法不对吗?

s5a0g9ez

s5a0g9ez3#

@type只能放在最先的位置,设计上就是这样的

相关问题