Jackson解析数据,部分数据缺失问题

IDEA0使用GsonFormat解析postman调试的json数据为对象,然后使用Jackson解析数据时,发现部分对象有数据,部分数据没有解析到.

PostMan调试出来的json数据

image.png

GsonFormat解析出来的对象

  @NoArgsConstructor
    @Data
    @AllArgsConstructor
    public static class DataBean implements Serializable {
        private List datalist;
        private PaginateBean paginate;

        @NoArgsConstructor
        @AllArgsConstructor
        @Data
        public static class PaginateBean implements Serializable {
            private int allList;
            private int currentPageIndex;
            private int pageSize;
            private int allPage;
        }

        @NoArgsConstructor
        @AllArgsConstructor
        @Data
        public static class DatalistBean implements Serializable {
            private String guid;
            private String updatedt;
            private String approvalno;
            private String TARGETCOST1;
            private String relateddocument;
            private String yearplan;
            private String relevantbasis;
            private String zjxzqt;
            private String sourceoffund;
            private String fundnature;
            private String basis;

Jackson解析没有数据

对比了下数据和生成对象发现有大小写转换和驼峰问题,需另外配置ObjectMapper这两个属性支持

  //支持全部字段全部小写
        this.mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
//同时支持驼峰和小写,需注释掉下面这句
//      this.mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);

你可能感兴趣的:(Jackson解析数据,部分数据缺失问题)