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)