I'm using JSON.net to parse the object data that I'm getting from a PHP script.
I'm able to get it to parse the array and break that down. Then once I try to parse each object within that array I'm getting this error:
Additional information: The best overloaded method match for
'Newtonsoft.Json.JsonConvert.DeserializeObject(string)'
has some invalid arguments
This is the function that is giving me errors:
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();
}
I just started learning C# last night, so I'm very new at this. Please let me know if you need more info.
What kind of object is 'JSON'? You need to pass in a string object for the DeserializeObject method to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With