fastjson FastJson对于一个对象中同一对象引用序列化不正确的问题

dfty9e19  于 2021-11-27  发布在  Java
关注(0)|答案(2)|浏览(304)

{
 "achievement":{
  "appActiveData":{
   "allNum":100,
   "name":"被扫",
   "yesNum":20
  },
  "authData":{"$ref":"$.achievement.appActiveData"},
  "scanData":{"$ref":"$.achievement.appActiveData"}
 },
 "dataChart":{
  "appActiveData":{
   "date":[
    "6/08"
   ],
   "num":[
    5
   ]
  },
  "authData":{"$ref":"$.dataChart.appActiveData"},
  "scanData":{"$ref":"$.dataChart.appActiveData"}
 }
}
{
 "achievement": {
  "scanData": {
   "name": "被扫",
   "allNum": 100,
   "yesNum": 20
  },
  "appActiveData": {
   "name": "被扫",
   "allNum": 100,
   "yesNum": 20
  },
  "authData": {
   "name": "被扫",
   "allNum": 100,
   "yesNum": 20
  }
 },
 "dataChart": {
  "scanData": {
   "date": ["6/08"],
   "num": [5]
  },
  "appActiveData": {
   "date": ["6/08"],
   "num": [5]
  },
  "authData": {
   "date": ["6/08"],
   "num": [5]
  }
 }
}
p4rjhz4m

p4rjhz4m1#

使用DisableCircularReferenceDetect关掉循环引用

JSON.toJSONString(object,SerializerFeature.DisableCircularReferenceDetect)
vfhzx4xs

vfhzx4xs2#

之前温少给了文档,已经解决了,有些用法没有很好的使用,感谢

相关问题