【发布时间】:2015-09-19 21:14:45
【问题描述】:
我有 PHP 文件,它给了我以下 JSON:
{"Name":"Waqas","Age":37,"Address":"Kanju"}
当我在 Windows Phone 中执行这个方法时,它给了我相同的 JSON:
{"Name":"Waqas","Age":37,"Address":"Kanju"}
在名为tblock.Text的文本块中;
这是我从 PHP 文件中以 JSON 格式接收数据的方法:
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();
这是我的课:
public class RootObject
{
public string Name { get; set; }
public int Age { get; set; }
public int Address { get; set; }
}
我想在TextboxName 中显示Name 值,类似于TextboxAge 中的Age 值和TextboxAddress 中的Address 值。我不知道该怎么做。
【问题讨论】:
-
开始阅读here。
标签: c# php json xaml windows-phone-8.1