Skip to content

Instantly share code, notes, and snippets.

@hexbinoct
Last active November 4, 2016 10:36
Show Gist options
  • Save hexbinoct/ffa22ee95d096759618e68e25f221892 to your computer and use it in GitHub Desktop.
Save hexbinoct/ffa22ee95d096759618e68e25f221892 to your computer and use it in GitHub Desktop.
class mainstructure
{
public List<c2> results;
public string status;
}
class c2
{
public List<address_component> address_components;
public string formatted_address;
public geometry geometry;
public string place_id;
public List<string> types;
}
class geometry
{
public location location;
public string location_type;
public two_locations bounds;
public two_locations viewport;
}
class two_locations
{
public location northeast, southwest;
}
class location
{
public double lat, lng;
}
class address_component
{
public string long_name, short_name;
public List<string> types;
}
/* Also a sample code to make a request and get a reply, just in case you having trouble doing that: */
string url_ = "http://maps.googleapis.com/maps/api/geocode/json?latlng={0},{1}&sensor=true";
string url_2 = string.Format(url_, "40.714224", "-73.961452");
WebRequest wr = WebRequest.Create(url_2);
WebResponse resp = wr.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string json = sr.ReadToEnd();
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
var ms = json_serializer.Deserialize<mainstructure>(json);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment