我試圖從JSON解析Json搜索結果,我正在使用JArray。解析JSON Twitter搜索
問題是這樣的,我可以解析某人的用戶名和結果會顯示,但是,當我試圖解析搜索API沒有任何顯示。這裏是我的代碼:
private void twitterClient()
{
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCompleted);
wc.DownloadStringAsync(new Uri("http://search.twitter.com/search.json?q=twitter&rpp=5&include_entities=true&result_type=mixed"));
}
void DownloadStringCompleted(object senders, DownloadStringCompletedEventArgs e)
{
try {
JArray twitterContent = JArray.Parse(e.Result);
}catch(Exception twit_error)
{
MessageBox.Show("Cannot parse");
}
}
正如你所看到的,URL存在,並且,如果我改變從搜索URL以某人的用戶名,它將解析和顯示這些結果。
希望有人能幫助我或提供一些建議。
假設您正在使用JSON.net? – spender