2016-12-05 34 views
-4
string json = @" {""data"":[{""Name"":""Yaj"",""Number"":""null"",""Name"":""null"",""PhotoUrl"":""http://worldforme.com/rfr/fr"",""date"":""1994-06-14 00:00:00.000"",""ID"":""178"",""ssid"":""1"",""InOut"":""Incoming"",""Intime"":""null"",""OutTime"":""null"",""Por"":""null""}]}"; 

var dt = JsonConvert.DeserializeObject<mainlist>(json); 

但是dt返回null!我需要反序列化JSON字符串

請幫

+2

你可以發佈你的'mainlist'類嗎? – Asnivor

回答

0

mainlist類需要結構化,以適應JSON字符串的鍵值。

下面是一個例子:

public class mainlist 
{ 
    public string Name {get; set;} 
    public int Number {get; set;} 
    [JsonProperty("PhotoUrl")] //Notice how this is different from the property name? 
           //This is because the property needs to fit exactly with the json string. 
    public string PhotoURL {get; set;} 
    //... 
} 

如果您仍然無法得到它,還有那麼就出錯了JSON字符串。

+1

是的,他做到了?它被稱爲主列表,他把類型。 – Dispersia

+0

Idk關於downvote,但啊,它在那裏,只是你的瀏覽器優化它作爲一個HTML代碼。得到它了。 – Dispersia