-
Notifications
You must be signed in to change notification settings - Fork 6.5k
循环引用
温高铁 edited this page Aug 2, 2013
·
6 revisions
fastjson支持循环引用,并且是缺省打开的。
当序列化后的JSON传输到浏览器或者其他语言中,这些json解析器不支持循环引用,从而导致数据丢失。你可以关闭fastjson的循环引用支持。
全局配置关闭
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
非全局关闭
JSON.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect);
{"$ref":"$"} | 引用根对象 |
{"$ref":"$"} | 引用根对象 |
{"$ref":"@"} | 引用自己 |
{"$ref":".."} | 引用父对象 |
{"$ref":"../.."} | 引用父对象的父对象 |
{"$ref":"$.members[0].reportTo"} | 基于路径的引用 |
如有需要修改本注脚,请联系阿里巴巴,
© Alibaba Fastjson Develop Team
注明: 版权所有阿里巴巴,请注明版权所有者
If you need to amend this footnote, please contact Alibaba.
© Alibaba Fastjson Develop Team
Note: Copyright Alibaba, please indicate the copyright owner