I'm doing a REST call to Bing-Driving Api:
http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.1=-22.57041,17.11387&wp.2=-22.57623,17.06172&key=...
After de-serialising the response:
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Response));
r = ser.ReadObject(stream) as Response;
I'm supposed to get the Route-object with:
var route = (r.ResourceSets[0].Resources[0] as Route)
But in my case r.ResourceSets[0].Resources[0] is only a BoundingBox-object! How do I get the Route? I can see in the raw-JSON, that everything is there.
The JSON data contract from here is added to my project:
http://msdn.microsoft.com/en-us/library/jj870778.aspx
Thanks Tom
Tom,
I was able to get those same data contracts (https://msdn.microsoft.com/en-us/library/jj870778.aspx) working in my project by making a few minor changes to the data contracts after I copied them into my solution. I should note that I am using Json.Net 6.0.3 for deserialization and not the DataContractJsonSerializer. I do not know if that makes a difference.
First I changed this:
to this (the only change was the addition of the generic type to the class and the ResourceSet property):
Then I changed this:
to this:
and everything worked.