alibaba / alibaba/fastjson2

JSONField 1.x 升级到2.x 命名规则失效

Open
#2,890 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description


com.alibaba
fastjson
2.0.52

@JSONField(name = "companyName")
private String companyName;

SerializeConfig config = new SerializeConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
config.put(User.class, new CustomSerializer());
User user = new User();
user.setCompanyName("123");
Object json = JSON.toJSON(user,config);
System.out.println("json = " + json);

定义了全局使用下划线,个别字段使用驼峰,2.x不生效 1.2.x版本是生效的

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided JSONField, SerializeConfig, PropertyNamingStrategy.SnakeCase, CustomSerializer, and JSON.toJSON example. Trace how the naming strategy and @JSONField(name = "companyName") are handled in the serialization entry point. Done means the 2.x behavior honors the explicitly named field while applying snake_case globally elsewhere.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.