考虑一下这个JSON:
{
"firstName": "John",
"lastName": "Doe",
"homeAddress": {
"streetAddress": "123 Main St",
"city": "Boston",
"state": "MA",
"postalCode": "02110"
},
"employmentInfo": {
"employerName": "ABC, Co.",
"phoneNumber": "617-555-5555"
}
}
public class Rootobject
{
public string firstName { get; set; }
public string lastName { get; set; }
public Homeaddress homeAddress { get; set; }
public Employmentinfo employmentInfo { get; set; }
}
public class Homeaddress
{
public string streetAddress { get; set; }
public string city { get; set; }
public string state { get; set; }
public string postalCode { get; set; }
}
public class Employmentinfo
{
public string employerName { get; set; }
public string phoneNumber { get; set; }
}
数字1没有任何意义。为什么会这样,有官方原因吗?数字2是有意义的,但是我希望能够改变行为,这样我的编译器就不会抱怨我的属性命名错误。
有办法调整这种行为吗?