fastjson JSON.parseObject(String, Clazz) causing NPE when List< > object is null

zsbz8rwp  于 2021-11-27  发布在  Java
关注(0)|答案(0)|浏览(168)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class A {

    private String a1;

    private List<B> bs;

    @Data
    @AllArgsConstructor
    @Builder
    public static class B {
        private List<C> cs; //List cause NPE, Map<C, String> or String or C will not
    }

    @Data
    @AllArgsConstructor
    @Builder
    public static class C {
        private String c1;
    }
}

String test = "{\"a1\":\"a1\",\"bs\":[{\"cs\":null}]}";
A response = JSON.parseObject(test, A.class); //NPE

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题