我跟隨代碼從網絡如何反序列化JSON在asp.net
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.bigflix.com/BIGFlixApi.do?parameter=getProductType&partnerID=17&uniqueID=54325345435×tamp=131286916367&digest=bf53cae8f364cfc1d796489d09e4cfd  <br>");
HttpWebResponse responce = (HttpWebResponse)request.GetResponse();
Stream resstream = responce.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resstream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
while (count > 0);
{
Response.Write(sb.ToString() + "<br/><br/>");
// string[] val = sb.ToString().Split('"');
}
要求運行此代碼後,我會得到這個類型的JSON
[
{ "id": 23, "name": "Video Clips" },
{ "id": 15, "name": "Deleted Scenes" },
{ "id": 9, "name": "Music Albums" },
{ "id": 7, "name": "Trailers" },
{ "id": 18, "name": "Short Films" },
{ "id": 21, "name": "Movie Clips" },
{ "id": 1, "name": "Movies " },
{ "id": 4, "name": "Plays" },
{ "id": 22, "name": "Scenes" },
{ "id": 2, "name": "TV Show" },
{ "id": 5, "name": "Kids" },
{ "id": 16, "name": "Interviews" },
{ "id": 11, "name": "Film Songs" },
{ "id": 14, "name": "Making of Movie" }
]
現在我想這反序列化在asp.net(c#)
我試圖得到一個正確的答案,但沒有得到。
請指教。
先生這是給錯誤錯誤不能隱式轉換類型'System.Collections.Generic .IList'到'string' –
Atul
你在這行後做了什麼?在此之後我寫回應 – naveen
。寫(性反應); – Atul