2016-12-05 11 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

関連する問題