如何在c#(windows Phone)中解析JSON数据?使用它

时间:2014-02-03 08:23:42

标签: c# parsing windows-phone-8

在Windows Phone App中..我正在通过(get,set)方法解析JSON数据 我有另一种处理来自this URL

的JSON数据的方法

在本网站的部分(http://www.dfg-team.com/json-feeds-on-windows-phone/?lang=en) 使用两种技术来解析json数据..

因为我想使用this.关键字来处理JSON数据..

但我的应用程序有数据有很多Json数据,其中包含许多JSON数组和JSON对象。但它不是一个问题,我有主要问题是我的json包含json对象内的Json数组或json数组内的json对象,所以在这里我们遇到了问题..

这是我想要解析这些字段的我的JSon数据..使用this.方法

{
"returnCode": "success",
"SData": {
    "results": [
        {
            "wdetails": [
                {
                    "noffers": [],
                    "offers_count": 0,
                    "name": "yahoo.com",
                    "recentoffers_count": 0,
                    "sku": "30072826",
                    "url": "http://www.yahoo.com"
                },
                {
                    "noffers": [
                        {
                            "id": "3aggEYoyaso",
                            "price": "179.99",
                            "firstrecorded_at": 13700,
                            "lastrecorded_at": 13700,
                            "seller": "google",
                            "availability": "In stock, ships same Business Day.",
                            "currency": "USD"
                        }
                    ],
                    "offers_count": 1,
                    "name": "frys.com",
                    "recentoffers_count": 1,
                    "sku": "789",
                    "url": "http://www.google.com"
                },
                {
                    "listprice_currency": "USD",
                    "noffers": [
                        {
                            "id": "2SlCKQKm",
                            "price": "192.37",
                            "firstrecorded_at": 111,
                            "lastrecorded_at": 111,
                            "seller": "Amazon",
                            "availability": "13 In Stock",
                            "currency": "USD"
                        }
                    ],
                    "offers_count": 1,
                    "name": "amazon.com",
                    "listprice": "288.56",
                    "recentoffers_count": 1,
                    "sku": "1084089",
                    "url": "http://www.amazon.com"
                }
            ],
            "model": "GGGG",
            "weight": "771107.03",
            "price_currency": "USD",
            "gtins": [
                "00839294"
            ],
            "mpn": "GGGG",
            "cat_id": "25552",
            "height": "98.81",
            "features": {
                "Product Type - General": "Tablet",
                "Height (in.)": "1.70"
            },
            "length": "416.56",
            "geo": [
                "usa"
            ],
            "width": "267.97",
            "category": "Tablets",
            "price": "179.99",
            "updated_at": 138,
            "color": "Black",
            "manufacturer": "google",
            "images_total": 1,
            "images": [
                "https://evbdn.eventbrite.com/s3-s3/eventlogos/1832816/google.png"
            ],
            "brand": "Dell",
            "offers_total": 180
        }
    ],
    "total_results_count": 1,
    "results_count": 1,
    "code": "OK",
    "offset": 0
  }
  }

我想在C#中使用this.解析它。

在android中我通过hash map方法完成此操作,在windows phone this.中类似于哈希映射,所以我正在使用它..

1 个答案:

答案 0 :(得分:1)

我正在编辑我以前的答案: -

JObject json = JObject.Parse(yourJson);

如果您需要解析结果

this.ClassOfResult=  json ["SData"]["results"];

如果你想要解析Json中的'wdetails',你可以试试这个

this.parentclass.wdetailsClass=  json ["SData"]["results"]["wdetails"];

希望这会给你一些想法。