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)

相关文章:

  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2021-10-18
  • 2021-10-28
  • 2021-05-09
  • 2021-06-09
  • 2021-07-21
  • 2021-10-21
相关资源
相似解决方案