2
請幫幫我,怎麼辦JSON解析在Windows Phone 7的使用給定的URL https://data.cityofchicago.org/api/views/xzkq-xp2w/rows.json?search=rahmJSON解析
請幫幫我,怎麼辦JSON解析在Windows Phone 7的使用給定的URL https://data.cityofchicago.org/api/views/xzkq-xp2w/rows.json?search=rahmJSON解析
newtonnsoft JSON庫添加到Visual Studio和使用此代碼
WebClient webClient = new WebClient();
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(downloadAboutCompleted);
webClient.OpenReadAsync(new Uri("https://data.cityofchicago.org/api/views/xzkq-xp2w/rows.json?search=rahm"), c);
private void downloadAlbumCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null && !e.Cancelled)
{
using (StreamReader httpwebStreamReader = new StreamReader(e.Result))
{
var results = httpwebStreamReader.ReadToEnd();
System.Diagnostics.Debug.WriteLine(results):
var json = JObject.Parse(results);
System.Diagnostics.Debug.WriteLine(json):
foreach (JObject array in json["meta"]["view"])
{
JObject obj = JObject.Parse(array.ToString());
string id= (string)obj["id"];
string name= (string)obj["name"];
System.Diagnostics.Debug.WriteLine(id + name):
}
}
}
}