当json列表中的项目为1时,我无法反序列化错误,当项目为>时,它会起作用。 1
这是我的json
{
"avetmiss": {
"disabilities": {
"disability": [
{
"disability-type": "Physical"
},
{
"disability-type": "Hearing/Deaf"
}
]
},
"prior-educations": {
"prior-education": {
"id": "2",
"prior-education-type": "Bachelor Degree or Higher Degree level"
}
}
}}
这是我反序列化的类
public class Root {
public PriorEducations prioreducations { get; set; }
[JsonProperty("disabilities")]
public Disabilities disabilities { get; set; }
}
public class Disabilities
{
[JsonProperty("disability")]
public List<DisabilityType> disability { get; set; }
}
public class DisabilityType
{
[JsonProperty("disability-type")]
public string disabilitytype { get; set; }
}
public class PriorEducations
{
[JsonProperty("prior-education")]
public List<PriorEducation> prioreducation { get; set; }
}
public class PriorEducation
{
[JsonProperty("id")]
public string id { get; set; }
[JsonProperty("prior-education-type")]
public string prioreducationtype { get; set; }
}
所以基本上它适用于Disabilities而不是之前的教育(因为Disabilities中的项目> 1,而之前的edu ..是1) 如果我将prioreducation []改为prioreducation
,它就有效