Skip to content

feat: add ObjectWriterProvider.disableListReferenceDetect switch - #7984

Open
zhengjiezxxy wants to merge 1 commit into
alibaba:mainfrom
zhengjiezxxy:feature/disable-list-reference-detect
Open

zhengjiezxxy wants to merge 1 commit into
alibaba:mainfrom
zhengjiezxxy:feature/disable-list-reference-detect

Conversation

@zhengjiezxxy

Copy link
Copy Markdown
  • Add provider-level switch (default false) that skips reference detection for Collection types
  • JSONWriter.setPath/setPath0: after pushing the path, return null when the value is an excluded Collection
  • fastjson1-compatible createWriteContext enables the switch to match fastjson 1.x list behavior
中文说明
  • 新增 ObjectWriterProvider 实例开关 disableListReferenceDetect(默认 false),开启后 Collection 类型不参与引用检测
  • JSONWriter.setPath/setPath0 在推入路径后判断,命中 Collection 时返回 null,不输出 $ref
  • fastjson1 兼容层 createWriteContext 开启该开关,保持 fastjson 1.x 的 list 序列化行为
  • 注意:开启后 list 的循环引用保护失效,自引用集合可能递归至 StackOverflowError

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

- Add provider-level switch (default false) that skips reference detection for Collection types
- JSONWriter.setPath/setPath0: after pushing the path, return null when the value is an excluded Collection
- fastjson1-compatible createWriteContext enables the switch to match fastjson 1.x list behavior

<details>
<summary>中文说明</summary>

- 新增 ObjectWriterProvider 实例开关 disableListReferenceDetect(默认 false),开启后 Collection 类型不参与引用检测
- JSONWriter.setPath/setPath0 在推入路径后判断,命中 Collection 时返回 null,不输出 $ref
- fastjson1 兼容层 createWriteContext 开启该开关,保持 fastjson 1.x 的 list 序列化行为
- 注意:开启后 list 的循环引用保护失效,自引用集合可能递归至 StackOverflowError
</details>

Co-authored-by: traeagent <traeagent@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants