Note that there are some explanatory texts on larger screens.

plurals
  1. POparse google maps geocode json response to object using Json.Net
    primarykey
    data
    text
    <p>I have a DB full of addresses I need to get lat and long for, so I want to loop through them and use Google Geocode to update my database. I am stuck as to how to parse the JSOn result to get what I need:</p> <pre><code>var address = "http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&amp;sensor=false"; var result = new System.Net.WebClient().DownloadString(address); GoogleGeoCodeResponse test = JsonConvert.DeserializeObject&lt;GoogleGeoCodeResponse&gt;(result); </code></pre> <p>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:</p> <pre><code>public class GoogleGeoCodeResponse { public string status { get; set; } public geometry geometry { get; set; } } public class geometry { public string location_type { get; set; } public location location { get; set; } } public class location { public string lat {get;set;} public string lng {get;set;} } </code></pre> <p>Here is a sample of what get's returned from Google:</p> <pre><code>{ "status": "OK", "results": [ { "types": [ "street_address" ], "formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", "address_components": [ { "long_name": "1600", "short_name": "1600", "types": [ "street_number" ] }, { "long_name": "Amphitheatre Pkwy", "short_name": "Amphitheatre Pkwy", "types": [ "route" ] }, { "long_name": "Mountain View", "short_name": "Mountain View", "types": [ "locality", "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" ] } ], "geometry": { "location": { "lat": 37.4219720, "lng": -122.0841430 }, "location_type": "ROOFTOP", "viewport": { "southwest": { "lat": 37.4188244, "lng": -122.0872906 }, "northeast": { "lat": 37.4251196, "lng": -122.0809954 } } } } ] } </code></pre> <p>I am missing simple here I know it, anyone?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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