1
這裏有什麼錯誤?我無法將其解析到列表中。JSON條紋格式異常
我試圖使用jsonUrl該文件得到JSON。
請讓我知道我在哪裏犯這個錯誤。
"recommended":[
{
"thumbnail":"http://farm8.staticflickr.com/7390/11919320035_1f6dd4da79_z.jpg",
"itemname":"Chilli Babycorn",
"itemtype":"veg",
"price":"45"
},
{
"thumbnail":"http://res.cloudinary.com/dhdglilcj/image/upload/v1455448132/foodonz/dishes/d7.jpg",
"itemname":"Honey Chilli Potato",
"itemtype":"veg",
"price":"90"
}
],
"veg starters":[
{
"itemname":"Paneer Tikka",
"itemtype":"veg",
"price":"110"
},
{
"itemname":"Aloo Tandoori",
"itemtype":"veg",
"price":"60"
}
]
}
這是itemsMenus類
請與上面的代碼有關它。
public class ItemsMenu {
private String thumbnail;
private String itemname;
private String price;
public String getItemtype() {
return itemtype;
}
public void setItemtype(String itemtype) {
this.itemtype = itemtype;
}
private String itemtype;
private String quantity="0";
public String getThumbnail() {
return thumbnail;
}
public void setThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getItemname() {
return itemname;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
}
也發佈您的項目菜單模型 – UMESH0492
爲什麼混合JSONArray/JSONObject API和Gson API?你只需要Gson在這裏解析你的字符串並將其映射到模型對象。 –