Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] 请问在fastjson2中,有禁止循环引用的功能吗,就是去掉 $ref 的意思 #2603

Open
156370005 opened this issue May 21, 2024 · 3 comments
Labels
question Further information is requested

Comments

@156370005
Copy link

fastjson1中,可以通过全局设置
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
或使用
JSON.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect);
来禁止循环引用

但在fastjson2中,找不到类似的功能。
在使用fastjson v1兼容版本中,也达不到fastjson1的效果。

谢谢!

@156370005 156370005 added the question Further information is requested label May 21, 2024
@wenshao
Copy link
Member

wenshao commented May 21, 2024

fastjson2中,缺省就是禁止引用检测的

@156370005
Copy link
Author

我指的是循环引用,不是引用,如果存在循环引用,fastjson2不使用JSONWriter.Feature.ReferenceDetection,是会报错的,但使用了JSONWriter.Feature.ReferenceDetection,又会出现$ref。

@156370005
Copy link
Author

我理解错了,不好意思,fastjson1在使用SerializerFeature.DisableCircularReferenceDetect时,如果有循环引用,也会报错。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants