2
我一直在咀嚼這兩天,並且無法使用我找到的示例使它工作。我真的很難與json解析。使用VB.net將Json字符串導入DataTable
所以我需要做的是將此字符串轉換爲數據表。我能夠達到我有字符串的地步,我只需要解析它。
{"total": 35799, "results": [{"publisher": "bamamatch.com", "first_seen": "2011-08-01", "times_seen": 1598, "monthly_uniques": null, "last_seen": "2013-04-02"}, {"publisher": "catholicdatingforfree.com", "first_seen": "2011-08-01", "times_seen": 1554, "monthly_uniques": null, "last_seen": "2013-04-02"}], "page_size": 100, "offset": 0}
你們可以告訴我一個清晰的方法來解析這個數據表使用VB.net嗎?
UPDATE
Dim url As String
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
url = "http://api.mixrank.com/v2/json/d73f10e7b22fbc69b79f0e0074913c14/advertisers/" & LCase(txtKeywords.Text) & "/gdn/publishers?page_size=100"
request = DirectCast(WebRequest.Create(url), HttpWebRequest)
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
Dim myDataTable As DataTable = DirectCast(JsonConvert.DeserializeObject(reader.ReadToEnd, (GetType(DataTable))), DataTable)
是否有這樣的理由,你需要在DataTable而不是自定義類?您可以使用Json.Net輕鬆地將響應序列化回對象圖。 – 2013-04-04 14:29:22