[alibaba/fastjson]反序列化问题

2024-09-20 695 views
3

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后,该数据则不会丢失

回答

3

最新版本扔出现问题

6

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

0

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