How to avoid null values serialization in HashMap?

前端 未结 5 609
夕颜
夕颜 2021-01-04 06:19

I would like to serialize a HashMap as a string through the Jackson JSON processor. For example:

String strMap = getMapper().writeValueAsString(myHashMap);
r         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 07:10

    Here is the latest annotation for ignoring the NULL fields

    @JsonSerialize(include= JsonSerialize.Inclusion.NON_NULL)

提交回复
热议问题