jackson - Jackson 中小写 Java 枚举常量的更好解决方案
问题描述
我正在寻找一种更好(更简洁)的解决方案,以便在 Jackson 中将大写的 Java 枚举常量序列化/反序列化为小写,而不是这个样板代码:
public enum GitLabPipelineStatusEnum {
@JsonProperty("canceled")
CANCELED,
@JsonProperty("created")
CREATED,
@JsonProperty("failed")
FAILED,
@JsonProperty("manual")
MANUAL,
解决方案
public enum GitLabPipelineStatusEnum {
CANCELED,
CREATED,
FAILED,
MANUAL,
@JsonValue
public String toLowerCase() {
return toString().toLowerCase();
}
}
参考
推荐阅读
- javascript - 如何在反应中取消socket.io-client订阅
- php - 如果指定的路由不存在,php slim 应用程序不会重定向到 index.php
- javascript - res.send XML 在 Express 中给出空文档
- python - 如何从python中的文本文件中提取特定数据
- ios - 将视图置于其他 SwiftUI 之上
- flutter - 如何检测手势检测器中的向上滑动?
- swift - 更改音频会话类别后 MPRemoteCommandCenter 不可用
- python - Numba 对具有类型参数的函数的无效使用
- sql-server - 更正命名管道的防火墙异常 (SQL Server)
- python - Python3 命令在我的虚拟环境中不起作用