日期:2014-05-17 浏览次数:20499 次
public class TempContacts
{
public string DisplayName { get; set; }
public string Email { get; set; }
}
string jsonContacts="[{\"DisplayName\":\"name1\",\"Email\":\"email1\"},{\"DisplayName\":\"name2\",\"Email\":\"email2\"}]";
Models.TempContacts contacts = JsonConvert.DeserializeObject<Models.TempContacts>(jsonContacts);
class Program
{
static void Main(string[] args)
{
string jsonContacts = "[{\"DisplayName\":\"name1\",\"Email\":\"email1\"},{\"DisplayName\":\"name2\",\"Email\":\"email2\"}]";
List<TempContacts> list = JsonConvert.DeserializeObject<List<TempContacts>>(jsonContacts);
}
}
public class Data
{
public List<TempContacts> list { get; set; }
}
public class TempContacts
{
public string DisplayName { get; set; }
public string Email { get; set; }
}
string jsonContacts="[{\"DisplayName\":\"name1\",\"Email\":\"email1\"},{\"DisplayName\":\"name2\",\"Email\":\"email2\"}]";
IList<Models.TempContacts> contactsList = JsonConvert.DeserializeObject<Models.TempContacts>(jsonContacts);