Android Parsing between JSON and Kotlin Object with Google Gson Library

Parsing between JSON and Kotlin Object with Google Gson Library

dependencies {
    ...
    implementation 'com.google.code.gson:gson:2.8.6'
    ...
}
class MyClass(val name:String?=null, val address:String?=null){}
val obj = MyClass("hangj", "earth")
val strjson = Gson().toJson(obj)
val obj2 = Gson().fromJson(strjson, MyClass::class.java)

posted on 2020-11-03 18:47  明天有风吹  阅读(83)  评论(0编辑  收藏  举报

导航

+V atob('d2h5X251bGw=')

请备注:from博客园