alibaba / alibaba/fastjson2

[QUESTION] fastjson1.x 升级fastjson2.x,FastJsonConfig字段dateFormat默认值有调整,能否可通过开关调整默认值?

Open
#3,723 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 请描述您的问题
FastJsonConfig 在fastjson1.x里,dateFormat默认值为null。
``` java
public class FastJsonConfig {
private Charset charset;
private String dateFormat;
}
```
在2.x里默认值为 "yyyy-MM-dd HH:mm:ss"
``` java
public class FastJsonConfig {
private Charset charset;
private String dateFormat = "yyyy-MM-dd HH:mm:ss";
}
```

目前我们在项目升级时,要求所有创建FastJsonConfig的地方使用统一的工具类创建,工具类里显式设置了dateFormat为null。

建议fastjson2.x里可以提供选项保持和1.x的默认一致。

Contributor guide

Open the contributing guide

Research direction

Start by locating FastJsonConfig and reviewing how its dateFormat default is initialized in fastjson2.x, then compare the compatibility requirements described for fastjson1.x. Define what the proposed switch should control and verify the behavior with the existing configuration or serialization tests; done means users can select the legacy default without requiring a separate utility class.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.