Skip to content

[BUG] PrettyFormat error #2974

@zanezhangzz

Description

@zanezhangzz

问题描述

PrettyFormat error

环境信息

请填写以下信息:

  • OS信息: macOS 15.0
  • JDK信息: Zulu21.34+19-CA (build 21.0.3+9-LTS)
  • 版本信息:Fastjson2 2.0.53

重现步骤

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));
}
{
	"name":"foo"
}
{
	
}

期待的正确结果

{
	"name":"foo"
}
{
	"name":"foo"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions