2011-07-22 68 views
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); 

回答

1

有在對象沒有道具因爲該對象包含與單個陣列數組中的單個對象。

+0

我修好了...... DUH哈哈......謝謝。 –

+0

內部類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 { 公共領域[]領域{得到;組; } } –