I search near by palce using google api
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+Sydney&key=YOUR_API_KEY
I want only vicinity information from result in json format.
Please advise how can I filter result and display only vicinity(address) information in json format.
String sURL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=";
sURL += objNearByServicesRequest.Latitude + "," + objNearByServicesRequest.Longitude;
sURL += "&radius=" + WebConfigurationManager.AppSettings["RadiusNearBySearch"] + "&types=" + objNearByServicesRequest.Types + "&keyword=" + objNearByServicesRequest.Keyword;
sURL += "&key=" + WebConfigurationManager.AppSettings["GoogleAPIKeyNearBySearch"];
String strreturn = String.Empty;
using (var client = new WebClient())
using (var stream = client.OpenRead(sURL))
using (var reader = new StreamReader(stream))
{
var jObject = Newtonsoft.Json.Linq.JObject.Parse(reader.ReadToEnd());
Console.WriteLine((string)jObject["results"][0]["vicinity"]);
}
I want to display out out in json format for 2 field like below.
how can I write code for display out put in below format using C#.
[
{
"id": 1,
"vicinity": "Opp. Railway Station, Gabba Estate,, Gohar Baug, Mumbai",
},
{
"id": 2
"vicinity": "SH 15, Navjivan Colony, Mumbai",
}
]
What I have tried:
how can I write code for display out put in below format using C#.
[
{
"id": 1,
"vicinity": "Opp. Railway Station, Gabba Estate,, Gohar Baug, Mumbai",
},
{
"id": 2
"vicinity": "SH 15, Navjivan Colony, Mumbai",
}
]