Jackson use JsonSerialize.Inclusion.NON_NULL except for one class

前端 未结 3 965
死守一世寂寞
死守一世寂寞 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条回答
  •  萌比男神i
    2021-02-05 07:44

    With Jackson 1.x you can use @JsonSerialize(include = Inclusion.ALWAYS) and with Jackson 2.x you can use @JsonInclude(Include.ALWAYS). These annotations will override the default config from your ObjectMapper.

提交回复
热议问题