以下解析 JSON 的代码不起作用。我究竟做错了什么?
string jsonText =
@"{
""John Doe"":{
""email"":""jdoe@gmail.com"",
""ph_no"":""4081231234"",
""address"":{
""house_no"":""10"",
""street"":""Macgregor Drive"",
""zip"":""12345""
}
},
""Jane Doe"":{
""email"":""jane@gmail.com"",
""ph_no"":""4081231111"",
""address"":{
""house_no"":""56"",
""street"":""Scott Street"",
""zip"":""12355""
}
}
}"
public class Address {
public string house_no { get; set; }
public string street { get; set; }
public string zip { get; set; }
}
public class Contact {
public string email { get; set; }
public string ph_no { get; set; }
public Address address { get; set; }
}
public class ContactList
{
public List<Contact> Contacts { get; set; }
}
class Program
{
static void Main(string[] args)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
ContactList cl = serializer.Deserialize<ContactList>(jsonText);
}
}
谢谢