【发布时间】:2015-07-27 10:15:16
【问题描述】:
假设这是我通过 API 收到的 JSON 数据...
var client = new HttpClient();
var uri = new Uri("blabla.com");
var response = await client.GetAsync(uri);
string result = await response.Content.ReadAsStringAsync();
[
{
“id”:“1”,
"title": "Test_rom",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.1.png"
},
{
"id": "2",
"title": "Jewelry",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.2.png"
},
{
"id": "3",
"title": "Jackets",
"subtitle": "All sizes available",
"icon": "http://lpl.info/Admin/upload/cat.3.png"
}
] 在此之后,我创建了一个类 RootObject ... 公共类 RootObject {
公共字符串 id { 获取;放; }
public string title { get; set; }
public string subtitle { get; set; }
public string icon { get; set; }
}
现在我只想显示“标题”键的值...(使用 C#)
RootObject TotalList = new RootObject();
字符串集线器 = " ";
foreach(TotalList.title 中的 var d)
{hub = hub + " " + d.ToString(); }
ResultsText.Text=hub;
但这是给出错误..请帮助
【问题讨论】:
-
第二,我之前问过,你用的是调试器吗?
-
三、贴出确切的错误
-
是的,我使用调试器...顺便说一句,我解决了这个问题:)