[BUG] JSONWriter.Feature.ReferenceDetection 无效
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
@JSONType(serializeFeatures = {JSONWriter.Feature.ReferenceDetection}) 无效
@JSONField(serializeFeatures = {JSONWriter.Feature.ReferenceDetection}) 无效
### 环境信息
*请填写以下信息:*
- OS信息: macOS 14.4.1
- JDK信息: java version "17.0.9" 2023-10-17 LTS
- 版本信息:fastjson2 2.0.50
### 重现步骤
*如何操作可以重现该问题:*
```java
@JSONType(serializeFeatures = {JSONWriter.Feature.ReferenceDetection})
public class A {
private B b;
}
@JSONType(serializeFeatures = {JSONWriter.Feature.ReferenceDetection})
public class B {
private A a;
}
JSONObject.toJSONString(a);
```
### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*
Contributor guide
Research direction
Start with the A/B reproducer and the JSONObject.toJSONString(a) entry point, then trace how JSONWriter.Feature.ReferenceDetection is applied to @JSONType and @JSONField annotations. Confirm the expected handling of the cyclic reference and add a regression test covering both annotation locations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100