java 实体转json 大小写问题

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

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

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

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 @ 2022-02-17 15:30  90的生力军  阅读(1178)  评论(0编辑  收藏  举报