java 实体转json 大小写问题

需求是List里的实体转JSON,JOSN KEY统一大写。默认不做控制KEY全部是小写,不论属性是怎么设置

1
autoExamineService.sendMsg(code, JsonMapper.defaultMapper().toJson(comprehensiveReportList));

后面修改comprehensiveReport实体如下即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.hginfo.icnocdata.domain.open;
 
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Component;
 
import java.io.Serializable;
 
/**
 * 综告请求参数实体
 * @Author yys
 * @Date 2022/2/17 13:35
 */
@Getter
@Setter
@Component
public class ComprehensiveReport implements Serializable {
    @JsonProperty("SOURCEIP")
    private String sourceip;
    @JsonProperty("AGENT")
    private String agent;
    @JsonProperty("IDENTIFIER")
    private Integer identifier;
    @JsonProperty("DOMAIN")
    private String domain;
    @JsonProperty("EMSNAME")
    private String emsname;
    @JsonProperty("NMSID")
    private String nmsid;
    @JsonProperty("NODE")
    private String node;
    @JsonProperty("NODEIP")
    private String nodeip;
    @JsonProperty("LOCATION")
    private String location;
    @JsonProperty("ALERTKEY")
    private String alertkey;
    @JsonProperty("ALERTTYPE")
    private String alerttype;
    @JsonProperty("SEVERITY")
    private Integer severity;
    @JsonProperty("FIRSTNETIME")
    private String firstnetime;
    @JsonProperty("LASTNETIME")
    private String lastnetime;
    @JsonProperty("SUMMARY")
    private String summary;
 
}

格式化后如图:

 

posted @   90的生力军  阅读(1189)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示