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
精彩评论