我需要帮助才能从RESTfull API中获取JSON。
这是我的回复
"variation_details": [
{
"variation_title": "Black Color",
"specifications": "Diamond Cut",
"image": [
"/uploads/variation-img0-0-Redmi J812127868.jpg"
],
"quantity": 10,
"price": 20000
}
],
我该如何删除[]。从响应开始,因为我需要在视图Pager中显示图像
这就是我从回复中得到的方式 http://devapi.dicatto.com[/uploads/variation-img0-0-Redmi J812127868.jpg]
这是我的完整答复
{
"code": true,
"success": "Records fetched successfully",
"result": {
"name": "Redmi J812127868",
"main_category": "5cde6e836340c5659e5c6992",
"sub_category": "5cde6f199aed456592c98f98",
"brand": "5cdeab466340c5659e5c69bd",
"model": "PROD771100",
"currency": "Rs",
"mrp_price": 18000,
"retailer_price": 17000,
"quantity": 30,
"available_quantity": null,
"avg_ratings": null,
"description": null,
"performance": null,
"other_infomation": null,
"product_description": "Test1234",
"specifications": "<p>RAM-4 </p>\n",
"features": [
{
"title": "RAM:4 GB,Memory:64 GB",
"description": "Test",
"image": "/uploads/feature-img0-Redmi J812127868.jpg"
}
],
"warranty": "12 Months",
"replacement": "Screen",
"same_day_delivery": null,
"discounted_amount": 2000,
"cash_on_delivery": null,
"manufacturing_details": "Test1232",
"importer_details": "Mumbai Test1232",
"packers_details": "Test123",
"offers": null,
"highlights": "Mumbai",
"more_info": null,
"keywords": null,
"manufacturer": null,
"variation_theme": "color",
"variation_details": [
{
"variation_title": "Black Color",
"specifications": "Diamond Cut",
"image": [
"/uploads/variation-img0-0-Redmi J812127868.jpg"
],
"quantity": 10,
"price": 20000
}
],
"__v": 0
}
}
多张图片出现时响应改变
"variation_details": [
{
"variation_title": "Black Color",
"specifications": "Diamond Cut",
"image": [
"/uploads/variation-img0-0-Redmi J812127868.jpg",
"/uploads/variation-img0-1-Redmi J812127868.jpg"
],
"quantity": 10,
"price": 20000
}
],
答案 0 :(得分:1)
Variation_details.java
public class Variation_details
{
private String[] image;
private String quantity;
private String price;
private String specifications;
private String variation_title;
public String[] getImage ()
{
return image;
}
public void setImage (String[] image)
{
this.image = image;
}
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 getSpecifications ()
{
return specifications;
}
public void setSpecifications (String specifications)
{
this.specifications = specifications;
}
public String getVariation_title ()
{
return variation_title;
}
public void setVariation_title (String variation_title)
{
this.variation_title = variation_title;
}
@Override
public String toString()
{
return "ClassPojo [image = "+image+", quantity = "+quantity+", price = "+price+", specifications = "+specifications+", variation_title = "+variation_title+"]";
}
}
Variation_details.getImage()[0];您可以获取图像密钥
答案 1 :(得分:0)
使用Pojo轻松获取响应数据。
使用Pojo,您可以通过简单的方法正确获取所有我们的响应数据。