我无法将JSON数组转换为GroupModel
array.下面是我使用的JSON:
[{
"description":"My expense to others",
"items":["aaa","bbb"],
"name":"My Expense"
},
{
"description":"My expense to others","
items":["aaa","bbb"],
"name":"My Expense"
}]
and the GroupModel
class is:
class GroupModel {
var name: String? = null
var description: String? = null
var items: MutableList<String>? = null
constructor(name: String, description: String, items: MutableList<String>) {
this.name = name
this.description = description
this.items = items
}
}
and trying the following code results in an Exception
:
通用域名格式.谷歌.格森.JsonSyntaxException:java.lang.IllegalStateException:应为
代码:
var model = gson.fromJson<Array<GroupModel>>(inputString, GroupModel::class.java)