【发布时间】:2017-10-17 13:20:44
【问题描述】:
我正在反序列化 JSON
{ “顶级专辑”:{ “专辑”:[ { "name":"贫民窟的百万富翁", “播放次数”:1442872, "url":"https://www.last.fm/music/A.R.+Rahman/Slumdog+Millionaire", “艺术家”:{ "name":"A.R. 拉赫曼", “mbid”:“e0bba708-bdd3-478d-84ea-c706413bedab”, "网址":"https://www.last.fm/music/A.R.+Rahman" }, “图片”:[ { "#text":"https://lastfm-img2.akamaized.net/i/u/34s/14c3f3bc7834415db7765563177e4bf6.png", “尺寸”:“小” }, { "#text":"https://lastfm-img2.akamaized.net/i/u/64s/14c3f3bc7834415db7765563177e4bf6.png", “大小”:“中” }, { "#text":"https://lastfm-img2.akamaized.net/i/u/174s/14c3f3bc7834415db7765563177e4bf6.png", “尺寸”:“大” }, { "#text":"https://lastfm-img2.akamaized.net/i/u/300x300/14c3f3bc7834415db7765563177e4bf6.png", “尺寸”:“超大” } ] } ] } }
string artist = txtMusic.Text;
var requestUrl = "http://ws.audioscrobbler.com/2.0/?method=artist.gettopalbums&artist=" + artist + "&api_key=&format=json";
var client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome / 58.0.3029.110 Safari / 537.36");
var response = client.DownloadString(requestUrl);
Response.Write(response);
dynamic stuff = JObject.Parse(response);
string name = stuff.album.name;
lblInfo.InnerText = name;
我无法弄清楚如何正确阅读它们。
【问题讨论】:
-
您遇到的错误是什么?
-
请把它格式化成可读的,然后我再读一遍,也许你会得到一些帮助。
-
System.Core.dll 中出现“Microsoft.CSharp.RuntimeBinder.RuntimeBinderException”类型的异常,但未在用户代码中处理其他信息:无法对空引用执行运行时绑定
-
绑定时出现异常