为了反序列化以下 Json,我使用了以下类组合,因此我可以四次循环层次结构,但它不起作用
我还没有找到任何反序列化此类 json 的教程非常感谢任何帮助
var myFoo = new JavaScriptSerializer().Deserialize<Commn.foo2>(@"
{""root"":
{""qss"":[
{""id"":""d1"",""qss"":[
{""id"":""qs1-1"",""tp"":""50px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs1-2"",""tp"":""100px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs1-3"",""tp"":""150px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs1-4"",""tp"":""200px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs1-5"",""tp"":""250px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs1-6"",""tp"":""300px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs1-7"",""tp"":""350px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs1-8"",""tp"":""400px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs1-9"",""tp"":""450px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs1-10"",""tp"":""500px"",""ck"":""c"",""dp"":""at""}]
}
{""id"":""d2"",""qss"":[
{""id"":""qs2-1"",""tp"":""50px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs2-2"",""tp"":""100px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs2-3"",""tp"":""150px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs2-4"",""tp"":""200px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs2-5"",""tp"":""250px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs2-6"",""tp"":""300px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs2-7"",""tp"":""350px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs2-8"",""tp"":""400px"",""ck"":""i"",""dp"":""at""},
{""id"":""qs2-9"",""tp"":""450px"",""ck"":""c"",""dp"":""at""},
{""id"":""qs2-10"",""tp"":""500px"",""ck"":""c"",""dp"":""at""}]
}
}
}
");
public class Pages
{
public string id { get; set; }
public qss[] children { get; set; }
}
public class qss
{
public string id { get; set; }
public string tp { get; set; }
public string ck { get; set; }
public string dp { get; set; }
}
/// <summary>
/// Holding the root elemnt
/// </summary>
public class foo2
{
public qss[] root { get; set; }
}