[BUG] PrettyFormat error
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
PrettyFormat error
### 环境信息
*请填写以下信息:*
- OS信息: macOS 15.0
- JDK信息: Zulu21.34+19-CA (build 21.0.3+9-LTS)
- 版本信息:Fastjson2 2.0.53
### 重现步骤
```java
record Person (String name) {}
public static void main(String[] args) throws JSONException {
var p = new Person("foo");
System.out.println(JSON.toJSONString(p, JSONWriter.Feature.PrettyFormat));
var jo = new JSONObject();
jo.put("name", "foo");
System.out.println(JSON.toJSONString(jo, JSONWriter.Feature.PrettyFormat));
}
```
```json
{
"name":"foo"
}
{
}
```
### 期待的正确结果
```json
{
"name":"foo"
}
{
"name":"foo"
}
```
Contributor guide
Research direction
Run the provided Java reproduction with Fastjson2 2.0.53, comparing PrettyFormat output for the Person record and JSONObject. Trace the PrettyFormat serialization entry point for both objects and add regression coverage for the expected name field; done means both examples produce the shown formatted JSON.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100