我有一个 php Web 服务,我试图在设计器中使用并将数据解析到我的文本框(我在 Windows 10 应用商店应用程序上工作),这是我的代码:
public sealed partial class MainPage : Page
{
public string uriString = "my URL";
public MainPage()
{
this.InitializeComponent();
Getdata();
}
private async void Getdata()
{
var http = new HttpClient();
http.MaxResponseContentBufferSize = Int32.MaxValue;
System.Collections.ArrayList response = new System.Collections.ArrayList(new string[] { await http.GetStringAsync(uriString) });
var rootObject = JsonConvert.DeserializeObject<Sponsorises.RootObject>(response); //the error is here
sponsorname.Text = rootObject.nom; //the name of my textBox
}
public class Sponsorises
{
internal class RootObject
{
public string nom { get; set; }
public string tel { get; set; }
public string photo { get; set; }
public string sponsorise_adrs { get; set; }
}
}
这是我的 json 代码:
{
success: 1,
message: "sponsorise found!",
total: 1,
sponsorises: [
{
nom: "my third local",
tel: "88888888",
photo: "http://192.168.1.1/1446241709_ab_cart2_bleu2.png",
sponsorise_adrs: "the adress"
}
]
}
我在将 arraylist 响应转换为字符串 rootObject 时遇到问题,您有什么想法吗,谢谢您的帮助