我正在使用 JSON.net 来解析我从 PHP 脚本中获取的对象数据。
我能够让它解析数组并将其分解。然后,一旦我尝试解析该数组中的每个对象,我就会收到此错误:
Additional information: The best overloaded method match for
'Newtonsoft.Json.JsonConvert.DeserializeObject(string)'
has some invalid arguments
这是给我错误的功能:
public void updateSearches()
{
var bw = new BackgroundWorker();
bw.DoWork += (send, args) =>
{
WebClient client = new WebClient();
JSON = client.DownloadString("URL");
dynObj = JsonConvert.DeserializeObject(JSON);
foreach (var item in dynObj)
{
dynamic search = JsonConvert.DeserializeObject(item);
foreach (var s in search)
{
joined += string.Join(",", s) + "END OF THE LINE\r\n";
}
}
};
bw.RunWorkerCompleted += (send, args) =>
{
this.mainWindow.richTextBox2.Text += "Got Data!\r\n";
this.mainWindow.richTextBox2.Text += joined;
};
bw.RunWorkerAsync();
}
我昨晚刚开始学习 C#,所以我对此很陌生。如果您需要更多信息,请告诉我。