[
{
"img":[
"http://inventory.vibhavpatil.com/productimages/912b4loRgiL._UL1500_.jpg",
"http://inventory.vibhavpatil.com/productimages/fdsfdsf.jpg"
],
"Colour":[
"Grey"
],
"Size":[
"Medium"
],
"productcode":"0001",
"productname":"Alan Jones Men\u0027s Cotton Printed T-Shirt",
"productbrand":"sousamoda",
"productcat":"clothing",
"productsubcat":"t-shirt",
"productmindec":"Look stylish and impressive",
"actualprice":"899",
"bestprice":"419",
"quantity":"5",
"designer":"Adidas"
}
]
以上是我的JSON輸出。JSON(Windows 10通用C#)
我可以設法得到其他單一輸出,例如產品代碼等。 但想獲得有關如何獲得「img [0]」和「img [1]」圖像鏈接的幫助。下面是我的代碼
class FullDetails
{
public string productcode { get; set; }
public string productname { get; set; }
public string productbrand { get; set; }
public string productcat { get; set; }
public string productsubcat { get; set; }
public string productmindec { get; set; }
public string actualprice { get; set; }
public string bestprice { get; set; }
public string quantity { get; set; }
public string designer { get; set; }
public List<string> img = new List<string>();
public List<string> Colour = new List<string>();
public List<string> Size = new List<string>();
}
我的C#代碼
Array obj = JArray.Parse(urlContents);
for (int i = 0; i < obj.Count; i++)
{
JObject row = JObject.Parse(obj[i].ToString());
try
{
var item1 = new FullDetails();
item1.productcode = row["productcode"].ToString();
item1.productname = row["productname"].ToString();
item1.productmindec = row["productmindec"].ToString();
item1.actualprice = row["actualprice"].ToString();
item1.bestprice = row["bestprice"].ToString();
item1.productbrand = row["productbrand"].ToString();
item1.productcat = row["productcat"].ToString();
item1.productsubcat = row["productsubcat"].ToString();
item1.quantity = row["quantity"].ToString();
item1.designer = row["designer"].ToString();
item1.img[0]= row["img"][0].ToString();
list1.Items.Add(item1);
}
catch
{
}
}
分享Json代碼不共享圖像 –
@gencklavyeler http://apisousa.vibhavpatil.com/justinproductsearch.aspx?p_code=0001鏈接將給出JSON輸出 –
@SirRufo我可以得到代碼的幫助嗎? –