C# JSON & Parsing
I have managed to set-up a simple webClient that calls my WCF service in a
WP8 application. The method fires perfectly fine and the data is returned
via the OpenReadCompleted event.
What I wish to do now is convert the returned data which is in JSON and
populate a collection of objects.
This is the webClient code:
private void Button_Click(object sender, RoutedEventArgs e)
{
var webClient = new WebClient();
var uri = new Uri("urlGoesHere");
webClient.OpenReadCompleted += webClient_OpenReadCompleted;
webClient.OpenReadAsync(uri);
}
This is the OpenReadComplete code:
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
var sr = new StreamReader(e.Result);
var data = sr.ReadToEnd();
//ToDo - Create a collection of SightingTypes and populate
sr.Close();
sr.Dispose();
}
And this is the POCO/Object which I want populating:
public class SightingType
{
public string Name { get; set; }
public string BrandId { get; set; }
}