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
val xiaoMing:Student=GSON.fromJson(xiaoMingJson)
val list:List<Student> =GSON.fromJson(classJson)
val studentMap:Map<String, Student> =GSON.fromJson(studentMapJson)
val map:Map<String, List<Student>> =GSON.fromJson(classMapJson)
或者:
val xiaoMing =GSON.fromJson<Student>(xiaoMingJson)
val list =GSON.fromJson<List<Student>>(classJson)
val studentMap =GSON.fromJson<Map<String, Student>>(studentMapJson)
val map =GSON.fromJson<Map<String, List<Student>>>(classMapJson)
通过 Kotlin 的扩展函数访问:
val xiaoMingJson ="""{name:"XiaoMing",age:22}"""val student = xiaoMingJson.toBean<Student>()
val list = classJson.toBean<List<Student>>()