Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing complex JSON
    text
    copied!<p>I want to parse a complex JSON on WP7. First I have to parse a JSON feed and I retrieve data to parse second JSON feed.</p> <p>To parse the first feed I use this web service <a href="http://horaires-ter-sncf.naholyr.fr/prochainsdeparts.php?gare=" rel="nofollow">http://horaires-ter-sncf.naholyr.fr/prochainsdeparts.php?gare=</a>... after that we use the code and the station's name to parse the second feed <a href="http://horaires-ter-sncf.naholyr.fr/prochainsdeparts.php?gare=....&amp;id=" rel="nofollow">http://horaires-ter-sncf.naholyr.fr/prochainsdeparts.php?gare=....&amp;id=</a>...</p> <p>This my code but it doesn't work:</p> <pre><code>public static class Parser { public static string resultats; public static reponse[] obj = new reponse[]{new reponse(),new reponse()}; public static reponse1 obj1 = new reponse1(); public static void HttpsCompleted_reponse(object sender, DownloadStringCompletedEventArgs e) { Horaire hre =new Horaire(); try { var ms = new MemoryStream(Encoding.Unicode.GetBytes(resultats)); var ser = new DataContractJsonSerializer(typeof(reponse1)); obj1 = (reponse1)ser.ReadObject(ms); } catch { WebClient wc = new WebClient(); //wc.DownloadStringCompleted += HttpsCompleted_reponse1; wc.DownloadStringAsync(new Uri("http://horaires-ter-sncf.naholyr.fr/prochainsdeparts.php?gare=" +hre.gettxt())); Debug.WriteLine("youuuuuuuuuuuuuuuuuuuuuuuppppppppppiiii"); } } /* public static void HttpsCompleted_reponse1(object sender, DownloadStringCompletedEventArgs e) { try { var ms = new MemoryStream(Encoding.Unicode.GetBytes(resultats)); var ser = new DataContractJsonSerializer(typeof(Gare)); obj1 = (reponse1)ser.ReadObject(ms); } catch { WebClient wc = new WebClient(); wc.DownloadStringCompleted += HttpsCompleted_reponse; wc.DownloadStringAsync(new Uri("http://horaires-ter-sncf.naholyr.fr/prochainsdeparts.php?gare=" + obj.success.Gares.Eleme + "&amp;id=" + obj.success.id)); } } */ } public class Depart { [DataMember(Name = "type")] public string type { get; set; } [DataMember(Name = "heure")] public string heure { get; set; } [DataMember(Name = "destination")] public string destination { get; set; } [DataMember(Name="attention")] public string attention { get; set; } [DataMember(Name = "retards")] public string [] retards { get; set; } [DataMember(Name = "source")] public string source { get; set; } public Depart() { } } public class Success { [DataMember(Name = "nom")] public string nom { get; set; } [DataMember(Name = "id")] public int id { get; set; } [DataMember(Name = "departs")] public Depart[] departs { get; set; } public Success() { this.departs = new Depart[0]; } } public class Success1 { [DataMember(Name="Gares")] public Gare[] Gares { get; set; } public Success1() { this.Gares = new Gare[0]; } } public class Gare{ [DataMember(Name="Nom")] public string Nom { get; set; } [DataMember(Name="code")] public int code { get; set; } public Gare() { } } public class reponse { [DataMember(Name = "code")] public string code{get;set;} [DataMember(Name = "success")] public Success1 success{get;set;} public reponse() { this.success = new Success1(); } } public class reponse1 { [DataMember(Name = "code")] public string code { get; set; } [DataMember(Name = "success")] public Success success { get; set; } public reponse1() { this.success = new Success(); } } private void button1_Click(object sender, RoutedEventArgs e) { //for (int i=0; i&lt;=Parser.obj1.Length;i++) Debug.WriteLine(Parser.obj1.success.nom); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload