0
我遇到了一些问题DeSerializing下面的Json,它运行时,抛出没有错误,但类中的道具都是null,所以它显然不工作。JavaScriptSerializer问题
{ "realms":[ { "type":"pve", "queue":false, "status":true, "population":"medium", "name":"Malfurion", "slug":"malfurion" } ] }
上面JSON是jsonResult串所以串jsonResult =以上JSON
我的代码:
public class Realm
{
public string type { get; set; }
public bool queue { get; set; }
public bool status { get; set; }
public string population { get; set; }
public string name { get; set; }
public string slug { get; set; }
}
var realm = javaScriptSerializer.Deserialize<Realm>(jsonResult);
我修好了...... DUH哈哈......谢谢。 –
内部类Realm { public string type {get;组; } public bool queue {get;组; } public bool status {get;组; } public string population {get;组; } public string name {get;组; } public string slug {get;组; } } 内部类RootObject { 公共领域[]领域{得到;组; } } –