Jackson use JsonSerialize.Inclusion.NON_NULL except for one class

前端 未结 3 881
死守一世寂寞
死守一世寂寞 2021-02-05 06:48

I normally use objectMapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL) because I never want the null values of my classes serialized. Except now I have a specif

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 07:33

    @user1433372, JsonInclude is an annotation only for Jackson 2.x.

    in Jackson 1.9

    @JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
    

    is the same in Jackson 2.x as

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    

提交回复
热议问题