I have PHP file which gives me following JSON:
{"Name":"Waqas","Age":37,"Address":"Kanju"}
When I execute this method in Windows Phone it gives me the same JSON:
{"Name":"Waqas","Age":37,"Address":"Kanju"}
in textblock named tblock.Text
;
This is my method for receiving data from PHP file in JSON format:
public async void sndandrec(string feedingaddress, HttpResponseMessage response, TextBlock tblock, HttpClient myhttpClient)
string responseText;
tblock.Text = "Waiting for response ...";
try
{
response = await myhttpClient.GetAsync(resourceUri);
response.EnsureSuccessStatusCode();
responseText = await response.Content.ReadAsStringAsync();
}
catch (Exception ex)
{
// Need to convert int HResult to hex string
tblock.Text = "Error = " + ex.HResult.ToString("X") +
" Message: " + ex.Message;
responseText = "";
}
tblock.Text = response.StatusCode + " " + response.ReasonPhrase;
tblock.Text = responseText.ToString();
This is my class:
public class RootObject
{
public string Name { get; set; }
public int Age { get; set; }
public int Address { get; set; }
}
I would like to show the Name
value in TextboxName
, similary Age
value in TextboxAge
and Address
value in TextboxAddress
. I don't know how to do that.