JSONField 1.x 升级到2.x 命名规则失效
- 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
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