我有一串像这样的JSON:
{
"letterstats":[
{"time_taken":636,"mistake_letters":"","the_letter":"L","success":true},
{"time_taken":216,"mistake_letters":"","the_letter":"U","success":true},
{"time_taken":103,"mistake_letters":"","the_letter":"I","success":true}
],
"word":"TEST"
}
我正在尝试使用JavaScriptSerializer来解析它,但我遇到了问题。这是我用来尝试解析的c#代码:
public class wordStats
{
public string word { get; set; }
List<letterStats> letterstats { get; set; }
public wordStats() { letterstats = new List<letterStats>(); }
}
public class letterStats
{
public int time_taken { get; set; }
public string mistake_letters { get; set; }
public string the_letter { get; set; }
public bool success { get; set; }
}
JavaScriptSerializer ser = new JavaScriptSerializer();
wordStats ws = ser.Deserialize<wordStats>(jsonObj);
它正在解析单词fine(“TEST”)但不解析数组。我不确定最新情况,我正在引用this以使其发挥作用。有谁知道出了什么问题?感谢
答案 0 :(得分:3)
letterstats
属性是私有的。
public class wordStats
{
public string word { get; set; }
public List<letterStats> letterstats { get; set; }
}