Skip to content

[QUESTION]如何让fastjson2的PrettyFormat输出达到fastjson之前一样的效果? #2972

@kay1003

Description

@kay1003

如何让fastjson2的PrettyFormat输出达到fastjson之前一样的效果?

FastJson2中格式化输出样式
JSON.toJSONString(jsonObject, JSONWriter.Feature.PrettyFormat)

{
	"type":1001,
	"job_id":[
		0,
		45732
	],
	"id":[
		1297059520,
		4117498193
	],
	"is_client":false,
	"stream_count":0
}

FastJson中格式化输出样式
JSON.toJSONString(jsonObject, Boolean.TRUE)

{
	"type":1001,
	"stream_count":0,
	"job_id":[0,45732],
	"id":[1297059520,4117498193],
	"is_client":false
}
  • 我该如何在fastjson2中做到fastjson之前的输出样式,不想让Json中数组的val展开换行

因为项目有解析前后对比换行后样式错乱

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions