gpt4 book ai didi

java - 如何在android中获取字符串数组

转载 作者:行者123 更新时间:2023-12-02 01:28:49 25 4
gpt4 key购买 nike

我需要帮助从 RESTful API 获取 JSON。

This is my Response

"variation_details": [
{
"variation_title": "Black Color",
"specifications": "Diamond Cut",
"image": [
"/uploads/variation-img0-0-Redmi J812127868.jpg"
],
"quantity": 10,
"price": 20000
}
],

how can i remove [] this. from response because i need to display image in view Pager

This is how i get From responsehttp://devapi.dicatto.com[/uploads/variation-img0-0-Redmi J812127868.jpg]

this is my full response

{
"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&nbsp;</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
}
}

The response change when multiple image come

"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
}
],

最佳答案

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];您可以获取图像 key

关于java - 如何在android中获取字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56438397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com