I am getting json response from this google api service to get reverse geo location from lat and long.
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
In the response JSON there are lot of rack [] of same names. How I can parse this JSON with newtonsoft to get country name.
WebClient wc = new WebClient();
var json = (JObject)JsonConvert.DeserializeObject(wc.DownloadString(url));
var country = json["results"]
.SelectMany(x => x["address_components"])
.FirstOrDefault(t => t["types"].First().ToString() == "country");
var name = country!=null ? country["long_name"].ToString() : "";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.