0

{"OFFERS":[{"OFFER_ID":"490","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/19007012.JPG","OFFER":"清仓库存"},{"OFFER_ID ":"488","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/36911135.JPG","OFFER":"最高 20% 折扣"},{"OFFER_ID":"487"," OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/19373615.JPG","OFFER":"最高 40% 折扣"},{"OFFER_ID":"486","OFFER_IMAGE":"http:// /www.discountbox.in/DiscountBoxUpload/16587130.JPG","OFFER":"特别折扣"},{"OFFER_ID":"485","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/ 56376547.JPG","OFFER":"最高 10% 折扣"},{"OFFER_ID":"484","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/20302235.JPG","OFFER":"Free Eye测试"},{"OFFER_ID":"483","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/14323344.JPG","OFFER":"Best Special Ra"},{"OFFER_ID" :"482","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/19790443.JPG","OFFER":"10% 折扣"},{"OFFER_ID":"481","OFFER_IMAGE ":"http://www.discountbox.in/DiscountBoxUpload/13783976.JPG","OFFER":"Flat 20% Off"},{"OFFER_ID":"480","OFFER_IMAGE":"http:// www.discountbox。in/DiscountBoxUpload/77105375.jpg","OFFER":"Flat 20% Off"},{"OFFER_ID":"479","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/91484956.jpg ","OFFER":"最高 50% 折扣"},{"OFFER_ID":"478","OFFER_IMAGE":"http://www.discountbox.in/DiscountBoxUpload/25738727.jpg","OFFER":"保险杠 Dhamaka"}]}

我需要将数据作为 OfferID、Image 和 Offer 存储在不同的变量中。有没有办法在 Visual Studio 2010 Express for Windows Phone 中做到这一点。请帮助。提前致谢

4

1 回答 1

0

使用http://json2csharp.com/创建一个要反序列化的类。

public class OFFER
{
    public string OFFER_ID { get; set; }
    public string OFFER_IMAGE { get; set; }
    public string OFFER { get; set; }
}

public class OfferResponse
{
    public List<OFFER> OFFERS { get; set; }
}

然后,使用Json.NET

var deserializedProduct = JsonConvert.DeserializeObject<OfferResponse>(json);
于 2012-04-04T20:15:06.890 回答