Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are several problems in your code. But even if you solved them you wouldn't be able to parse the list of received stations with <code>DataContractJsonSerializer</code> out of the box.</p> <p><strong>Explanation:</strong></p> <p><a href="http://horaires-ter-sncf.naholyr.fr/?p=ws" rel="nofollow noreferrer">The web site offering the web service you are using</a> says a response from your first "JSON feed" looks like this:</p> <blockquote> <p>{"code":201,"success":{"gares":{"villefranche-d''alb.-ce":1750,"villefranche de rgue-12":1749,...}}}</p> </blockquote> <p>Have a look at the stations and their IDs:</p> <blockquote> <p>{"villefranche-d''alb.-ce":1750,"villefranche de rgue-12":1749,...}</p> </blockquote> <p>This is an associative array where the keys and values are not explicitly decorated with "Key" and "Value". But these decorations are necessary for <code>DataContractJsonSerializer</code> to parse the JSON. They would have to be in format </p> <blockquote> <p>[{“Key”:“villefranche-d''alb.-ce”,“Value”:“1750”},{“Key”:“villefranche de rgue-12”,“Value”:“1749”}]</p> </blockquote> <p>to be properly parsed by <code>DataContractJsonSerializer</code>. (The reason is that this serializer supports more complex types than <code>int</code> and <code>string</code> to be used as keys and values.)</p> <p><a href="http://theburningmonk.com/2011/05/json-serialization-datacontractjsonserializer-vs-javascriptserializer/" rel="nofollow noreferrer">This blog post</a> contains a very good description of the matter and how <code>JavaScriptSerializer</code> could be the solution. But unfortunately this class isn't available in Silverlight.</p> <p>More people having similar problems like you:</p> <ul> <li><a href="https://stackoverflow.com/questions/596271/deserialization-problem-with-datacontractjsonserializer">Deserialization problem with DataContractJsonSerializer</a></li> <li><a href="https://stackoverflow.com/questions/2826653/net-can-i-use-datacontractjsonserializer-to-serialize-to-a-json-associative-ar">.NET: Can I use DataContractJsonSerializer to serialize to a JSON associative array?</a></li> <li><a href="https://json.codeplex.com/discussions/258083" rel="nofollow noreferrer">https://json.codeplex.com/discussions/258083</a></li> <li><a href="https://connect.microsoft.com/VisualStudio/feedback/details/558686/" rel="nofollow noreferrer">https://connect.microsoft.com/VisualStudio/feedback/details/558686/</a></li> </ul> <p><strong>Solution:</strong></p> <p>Use <a href="https://json.codeplex.com/" rel="nofollow noreferrer">Json.NET</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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