fastjson2 icon indicating copy to clipboard operation
fastjson2 copied to clipboard

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

Open QQQJoker opened this issue 1 year ago • 0 comments

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>2.0.52</version>
    </dependency>

@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版本是生效的

QQQJoker avatar Aug 22 '24 10:08 QQQJoker