开发者

Using gson, how to exclude a numeric type (double, integer) with default value from serialization?

I am using gson for serialization and running into a problem. In the class "Person" I defined, there is a field "age", whose type is "int". This field is defaulted to 0 unless it is reset later. In serializing an object of Person, I want t开发者_如何学Goo exclude the field "age" if it is value is still 0. Can anybody tell me how to do that using gson?

Thanks,

Jianguo


  • gson custom serialization
  • excluding fields
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜