我从下面的 webRequest 得到响应是代码,
HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
using (var twitpicResponse = (HttpWebResponse)request.GetResponse())
{
using (var reader = new StreamReader(twitpicResponse.GetResponseStream()))
{
JavaScriptSerializer js = new JavaScriptSerializer();
var objText = reader.ReadToEnd();
while (reader.EndOfStream)
{
objText = reader.ReadLine();
MyObject myobj= (MyObject)js.Deserialize<MyObject>(objText);
}
}
}
我收到以下格式的 JSON 响应,我想将此 JSON 响应与 myobj 绑定。
{"Results":[{"Id":"571611","ModerationStatus":"APPROVED","LastModificationTime":
"2011-10-31T05:36:33-05:00"
,"IsRatingsOnly":true,"TotalCommentCount":0,"Rating":5,"RatingRange":5,"IsRecommended":true,"TotalFeedbackCount":0,"TotalPositiveFeedbackCount":0,"TotalNegativeFeedbackCount":0,"DisplayLocale":"en_US","SubmissionTime":
"2011-05-25T00:00:00-05:00"
,"IsFeatured":false,"LastModeratedTime":
"2011-10-31T05:36:33-05:00"
,"ProductId":"3240234","AuthorId":"z7knrbjunvi022pe4swqp18fra"},{"Id":"571612","ModerationStatus":"APPROVED","LastModificationTime":
"2011-10-31T05:36:33-05:00"
,"IsRatingsOnly":true,"TotalCommentCount":0,"Rating":5,"RatingRange":5,"IsRecommended":true,"TotalFeedbackCount":0,"TotalPositiveFeedbackCount":0,"TotalNegativeFeedbackCount":0,"DisplayLocale":"en_US","SubmissionTime":
"2011-05-25T00:00:00-05:00"
,"IsFeatured":false,"LastModeratedTime":
"2011-10-31T05:36:33-05:00"
,"ProductId":"3240234","AuthorId":"zsknvekklaxl56nzwliultz5mp"}],"Includes":{"Products":{"3240234":{"Id":"3240234","Name":"Rosner Chevrolet","Description":"Brevard County","BrandExternalId":"01","Brand":{"Id":"01","Name":"Personal Accounts"},"CategoryId":"324","ProductPageUrl":"https://www.sccu.com/personal/vehicle-loans/dealer-review.asp?did=234&dealerName=Rosner+Chevrolet"}},"Authors":{"z7knrbjunvi022pe4swqp18fra":{"Id":"z7knrbjunvi022pe4swqp18fra","ModerationStatus":"NONE"},"zsknvekklaxl56nzwliultz5mp":{"Id":"zsknvekklaxl56nzwliultz5mp","ModerationStatus":"NONE"}}},"HasErrors":false,"Offset":0,"Limit":2,"TotalResults":25}
我想一一读取这个 JSON 块(这个 JSON 块具有多个值)并存储到对象列表中。