2

助けてください、与えられたURLを使用してWindowsPhone7でjson解析を行う方法はhttps://data.cityofchicago.org/api/views/xzkq-xp2w/rows.json?search=rahmです

4

1 に答える 1

0

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):
                    }

                }

            }
        }
于 2013-03-01T15:44:25.053 に答える