gpt4 book ai didi

java - 使用 Jackson 将带有下划线的 JSON 反序列化为 Java 中的驼峰式大小写?

转载 作者:搜寻专家 更新时间:2023-10-30 21:32:43 24 4
gpt4 key购买 nike

<分区>

为了将带有驼峰式属性的 java 对象序列化为带有下划线的 json,我们使用 PropertyNamingStrategy 作为 SNAKE_CASE

那么,有没有什么事情可以做相反的事情呢?即,将带下划线的json反序列化为驼峰大小写的Java对象。

例如,这个 JSON:

{
"user_id": "213sdadl"
"channel_id": "asd213l"
}

应该反序列化为这个 Java 对象:

public class User {
String userId; // should have value "213sdadl"
String channelId; // should have value "asd213l"
}

我知道one way of doing this这是通过在字段级别工作的 @JsonProperty 注释。我有兴趣了解这方面的任何全局设置。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com