I am new to windows phone 8 development. I am working on application in which I need parse the Json. so I am not able to get the following data in windows phone 8.
{
"response":{
"errorFlag":0,
"Score Detail":{
"39":[
{
"test_date":"2013-06-28",
"total_marks":"50",
"score":"14"
},
{
"test_date":"2013-08-08",
"total_marks":"20",
"score":"20"
}
],
"40":[
{
"test_date":"2013-08-08",
"total_marks":"20",
"score":"20"
},
{
"test_date":"2013-08-08",
"total_marks":"30",
"score":"20"
},
{
"test_date":"2013-08-08",
"total_marks":"30",
"score":"20"
}
],
"50":[
{
"test_date":"2013-08-08",
"total_marks":"30",
"score":"20"
}
]
}
}
}
I am trying to parse the data in the following way
namespace testscore
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Mainpage_Loaded);
}
void Mainpage_Loaded(object sender, RoutedEventArgs e)
{
WebClient webClient1 = new WebClient();
webClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient1_DownloadStringCompleted);
webClient1.DownloadStringAsync(new Uri("some link"));
}
public void webClient1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var rootObject = JsonConvert.DeserializeObject<RootObject>(e.Result);
MessageBox.Show(e.Result.ToString());
foreach (var res in rootObject.response.ScoreDetail)
{
string rs = res.Key;
MessageBox.Show(rs.ToString());
......
}
}
public class RootObject
{
public Response response { get; set; }
}
public class Response
{
public int errorFlag { get; set; }
[JsonProperty("Score Detail")]
public JObject ScoreDetail { get; set; }
}
Here I am to getting key value (here it is 39) but I am not able to get the values of the score, testdate and marks. please help me in parsing these details.
Thanks in advance.