Android_Question icon indicating copy to clipboard operation
Android_Question copied to clipboard

gson序列化数据时如何排除某个字段?

Open whatshappen opened this issue 5 years ago • 1 comments

whatshappen avatar Apr 03 '19 00:04 whatshappen

方式一:给字段加上 transient 修饰符

方式二:排除Modifier指定类型的字段。这个方法需要用GsonBuilder定制一个GSON实例。

方式三:使用@Expose注解。没有被 @Expose 标注的字段会被排除

whatshappen avatar Apr 03 '19 00:04 whatshappen