1.通过@Since和@Until设置需要转换的区间
data class UserBean(
var name: String? = null,
var age: Int = 0,
@Since(-999.0)
@Until(-999.0)
var sex: Int = 0
)
2.通过版本控制是否需要过滤
GsonBuilder().setVersion(0.0).create().toJson(userBean)
data class UserBean(
var name: String? = null,
var age: Int = 0,
@Since(-999.0)
@Until(-999.0)
var sex: Int = 0
)
GsonBuilder().setVersion(0.0).create().toJson(userBean)
本文标题:2019-09-02 Gson将Bean转换为Json时过滤掉某
本文链接:https://www.haomeiwen.com/subject/imaqyctx.html
网友评论