I thought I could simply build a quick class and use JSON.Net to deserialize the result, and it is kind of working but I think I am blowing it on my class structure:
public class Location
{
public string lat { get; set; }
public string lng { get; set; }
}
public class Geometry
{
public Location location { get; set; }
}
public class Json
{
public Results results { get; set; }
}
public class Results
{
public Json json { get; set; }
public Geometry geometry { get; set; }
}
public class Query
{
public Results results { get; set; }
}
public class RootObject
{
public Query query { get; set; }
}
Here is a sample of what get's returned from Google:
{
"results" : [
{
"address_components" : [
{
"long_name" : "1600",
"short_name" : "1600",
"types" : [ "street_number" ]
},
{
"long_name" : "Amphitheatre Parkway",
"short_name" : "Amphitheatre Pkwy",
"types" : [ "route" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Santa Clara",
"short_name" : "Santa Clara",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "94043",
"short_name" : "94043",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
"geometry" : {
"location" : {
"lat" : 37.42244920,
"lng" : -122.08506440
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 37.42379818029150,
"lng" : -122.0837154197085
},
"southwest" : {
"lat" : 37.42110021970850,
"lng" : -122.0864133802915
}
}
},
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
I am missing simple here I know it, anyone?