how to config gson to exclude 0 integer values

前端 未结 4 1416
囚心锁ツ
囚心锁ツ 2020-12-18 21:41

I\'ve a Java class with lot of integer fields and when I want to serialize them to json string due to some of them could have no value, hence after serializing all integers

4条回答
  •  旧巷少年郎
    2020-12-18 22:21

    We have to just use class Integer (Integer javadoc).

    class Example {
       String title = "something";
       Integer id = 22;
       Integer userId;
    }
    

提交回复
热议问题