如何解析嵌套对象
[{
"id": 100500,
"products": "[{\"id\":45,\"title\":\"All Product\"]"
}]
模型类
public class Store {
public long id;
public List<Product> products;
}
答案 0 :(得分:1)
不会解析
public class Store {
public long id;
public List<Product> products;
}
Gson mGson= new Gson();
storeList=mGson.fromJson(json, Store.class);
storeList.getStores().get(0).getProducts().get(1);
答案 1 :(得分:1)
嗨,你把Gson改成
{
"Id": "100500",
"products": [
{
"id": 1,
"title": "title 1"
},
{
"id": 2,
"title": "title 2"
},
{
"id": 3,
"title": "title 3"
}
]
}