You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
data class ObjectA(
@JSONField(serialize = false)
var a:String?=""
){
fun getB():String? = this.a
fun setB(v:String){
this.a = "b"
}
}
fun testjson3(){
var a:ObjectA = ObjectA()
a.a = "c"
val json:String = JSON.toJSONString(a)
println(json)
val obj:ObjectA = JSON.parseObject(json, ObjectA::class.java)
println(obj)
}
序列化操作时,想隐藏字段。所以data class里属性设置为serialize =false。
输出结果:
toJSONString()的时候,执行了getB()方法。
parseObject()的时候,没有执行setB()这个方法。
使用的fastjson 版本是 1.2.37
kotlin版本是1.1.4-2
在java版本里这样子操作是正常的。kotlin不执行set方法。求解决!
The text was updated successfully, but these errors were encountered: