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

相关问题