I ' m using the geocode API's Google, I can get the JSON string with all dates , but when i will convert it in a object, it do not work, it return anything,I'm using the JSON.NET, i'm doing something wrong ?
in all JSON data, I wanna just take the formatted_address.
json request : http://maps.googleapis.com/maps/api/geocode/json?address=av.paulista&sensor=false%22
sorry my bad English
my main form: getting the JSON data(working)
private void btnConsumir_Click(object sender, EventArgs e)
{
string address = txtAddress.Text ;
string searchCode = "http://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&sensor=false";
var JSONdata = "";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(searchCode);
httpWebRequest.ContentType = "text/json";
httpWebRequest.Method = "POST";
var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
JSONdata = streamReader.ReadToEnd();
}
lblJSON.Text = JSONdata;//its a label
here i want get the formatted_address information on json:
[...]
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
JSONdata = streamReader.ReadToEnd();
}
lblJSON.Text = JSONdata;//its a label
AddressObject addressObject = JsonConvert.DeserializeObject<addressObject>(JSONdata);
string result = addressObject.formatted_address;
lblJSON.Text = result;
and this is my class object:
class AddressObject
{
public string formatted_address { get; set; }
}
thank you so much!