【发布时间】:2016-12-14 07:33:14
【问题描述】:
我有 json:
{
"id": 1,
"result": [
{
"id": 1,
"imgUrl": "http://test.com/image.jpg",
"title": "image"
},
{
"id": 2,
"imgUrl": "http://test.com/image2.jpg",
"title": "image2"
}
],
"jsonrpc": "2.0"
}
我如何解析内部数组,我尝试使用模型进行默认的 retroif gson 解析
public class TestRequest {
public int id;
public List<ArrayItems> result;
public String jsonrpc;
}
public class Item {
public int id;
public String imgUrl;
public String title;
}
我有错误:预期为 BEGIN_OBJECT,但为 BEGIN_ARRAY。 然后我尝试手动解析
Item[] items = GSON.fromJson(json, Item[].class);
并且有错误:
应为 BEGIN_ARRAY,但为 BEGIN_OBJECT。
我们要做什么?
【问题讨论】: