我收到了来自 Twitter 搜索的 JSON 响应,但我如何循环浏览它们?
protected void BtnSearchClick(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://search.twitter.com/search.json?&q=felipe&rpp=40");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);// fill the buffer with data
if (count != 0)// make sure we read some data
{
tempString = Encoding.ASCII.GetString(buf, 0, count);// translate from bytes to ASCII text
sb.Append(tempString);// continue building the string
}
}
while (count > 0); // any more data to read?
//HttpContext.Current.Response.Write(sb.ToString()); //I can see my JSON response here
//object deserializeObject = Newtonsoft.Json.JsonConvert.SerializeObject(sb.ToString());
}