我是 windows phone 8 开发的新手...如何在 windows phone 8 中解析以下数据:
[
{
"detail":{
"single_selection":[
{
"Questions":"If -2<1\/2x< 4 , then",
"Question Type":"text",
"Url":"NO URL",
"options":{
"2379":"4 > x < -8",
"2380":"4 < x > -8",
"2381":"4 < x < -8",
"2382":"4 > x > -8"
},
"correct Ans":[
"2382"
],
"marks":"1",
"description":"4 > x > -8"
}
]
}
}
]
我正在尝试通过以下方式解析:
namespace TestSample
{
public partial class MainPage : PhoneApplicationPage
{
private const string Con_String = @"isostore:/DataBase.sdf";
// Constructor
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri("SomeURL"));
}
public void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var rootObject = JsonConvert.DeserializeObject<RootObject1[]>(e.Result);
foreach (var r in rootObject)
{
var s = r.detail.single_selection;
for (int i = 0; i < s.Count; i++)
{
}
}
}
public class RootObject1
{
public Detail detail { get; set; }
[JsonProperty("total questions and marks")]
public List<TotalQuestionsAndMark> totalquestionsandmarks { get; set; }
}
public class TotalQuestionsAndMark
{
[JsonProperty("total questions")]
public int totalquestions { get; set; }
[JsonProperty("total test marks")]
public int totaltestmarks { get; set; }
public string Duration { get; set; }
}
public class Detail
{
public List<SingleSelection> single_selection { get; set; }
}
public class SingleSelection
{
public string Questions { get; set; }
[JsonProperty("Question Type")]
public string QuestionType { get; set; }
public string Url { get; set; }
public string marks { get; set; }
public string description { get; set; }
public Options option { get; set; }
[JsonProperty("correct Ans")]
public List<string> correctAns { get; set; }
}
public class Options
{
public string optionid { get; set; }
public string option_name { get; set; }
}
}
}
我能够解析一些数据,但我不知道如何解析选项..请帮助我解析完整的代码。请帮助我解析完整的数据......提前谢谢......