alibaba / fastjson

FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
https://github.com/alibaba/fastjson2/wiki/fastjson_1_upgrade_cn
Apache License 2.0
25.73k stars 6.5k forks source link

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

Open QQQJoker opened 1 month ago

QQQJoker commented 1 month ago
@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.x版本是生效的