我在解析 json 数据时遇到了这个错误
Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
我找不到解决方案。我的 json 数据是:
{
"user": [
{
"email": "wijden@jerseyrest.com",
"firstName": "Wijden",
"id": "1",
"lastName": "User"
}, {
"email": "user@jerseyrest.com",
"firstName": "Sample",
"id": "2",
"lastName": "User"
}, {
"email": "ingenieur@jerseyrest.com",
"firstName": "Ingenieur",
"id": "3",
"lastName": "User"
}
]
}
我就是这样做的:
Type type = new TypeToken<List<WorkItem>>() { }.getType();
List<WorkItem> workitems = (List<WorkItem>) new Gson().fromJson(resultat, type);
如果您能帮我解决 tnis 问题,我将不胜感激。提前致谢