fastjson WriteNullListAsEmpty生效时, 且field类型为enum, 值为null. 输出错误

4ktjp1zp  于 2022-11-02  发布在  其他
关注(0)|答案(1)|浏览(163)
  • WriteNullListAsEmpty生效时, 且field类型为enum, 值为null. 序列化结果中包含该field且值为null. 期望为不存在在filed
SerializerFeature[] serializerFeatures = Lists.newArrayList(
                SerializerFeature.WriteNullListAsEmpty)
                .stream()
                .toArray(SerializerFeature[]::new);

        String s = JSONObject.toJSONString(Resp1.builder()
                        .key("key1")
                        .build(),
                serializerFeatures);

{"anEnum":null,"key":"key1"}

相关问题