Parsing JSON in a Windows Phone Application

Call a web-service for JSON data

WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri(“http://somedomain.com/xyz/myjson.aspx”));

 

//
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var rootObject = JsonConvert.DeserializeObject(e.Result);

foreach (var book in rootObject.MyBookList)
{
Console.WriteLine(book.TITLE);
} }

Leave a comment