CandidateResume' class 不支持对数组进行反序列化
CandidateResume' class is not supported for deserialization of an array
我正在尝试以这种方式反序列化数组,但我收到了那个错误。
JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
var myobj = jsSerializer.Deserialize<CandidateResume[]>(json);
这是我的 json 文件
[
[
{
"name":"Riaz Kabir",
"url":"https://recruit.theladders.com/resumeviewer?jobseekerId=01-sid-BDLBKUPMIL6HGZ22MOAJJIWYGE",
"summary":"ASP.NET MVC Developer Hewlett-Packard (HP) (1/2013-Present) Location: Schenectady, NY Compensation: k+ Previous Titles/Companies: 2016 ►",
"role":"ASP.NET MVC Developer at Hewlett-Packard (HP)",
"compensation":"k+",
"education":"BS, Computer Science and Engineering, Asian University of Bangladesh",
"expertise":"Databases , IT Consulting , Software Development , Front End Development",
"years":"Less than 5",
"relocation":"Schenectady, NY Within 1000 miles of 12305 Would need to relocate here",
"resume":"0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAP",
"resumeExtension":"doc",
"resumeMimeType":"application/msword"
}
]
]
下面是我的候选人简历class
public class CandidateResume
{
public string name { get; set; }
public string url { get; set; }
public string summary { get; set; }
public string role { get; set; }
public string compensation { get; set; }
public string education { get; set; }
public string expertise { get; set; }
public string years { get; set; }
public string relocation { get; set; }
public string resume { get; set; }
public string resumeExtension { get; set; }
public string resumeMimeType { get; set; }
}
错误消息:CandidateResume' 不支持反序列化数组。
你的JSON是一个列表中的列表。考虑错误 CandidateResume is not supported for deserialization of an array.
It's trying to deserialize an array to a CandidateResume
object.
改为尝试:
var myobj = jsSerializer.Deserialize<List<List<CandidateResume>>>(json);
或者将您的 JSON 更改为不是列表的列表。
在 json 中,您有额外的“[”和“]”。只需删除它们。
或者,如果它不可接受,您可以尝试
var myobj = jsSerializer.Deserialize<CandidateResume[][]>(json);
我正在尝试以这种方式反序列化数组,但我收到了那个错误。
JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
var myobj = jsSerializer.Deserialize<CandidateResume[]>(json);
这是我的 json 文件
[
[
{
"name":"Riaz Kabir",
"url":"https://recruit.theladders.com/resumeviewer?jobseekerId=01-sid-BDLBKUPMIL6HGZ22MOAJJIWYGE",
"summary":"ASP.NET MVC Developer Hewlett-Packard (HP) (1/2013-Present) Location: Schenectady, NY Compensation: k+ Previous Titles/Companies: 2016 ►",
"role":"ASP.NET MVC Developer at Hewlett-Packard (HP)",
"compensation":"k+",
"education":"BS, Computer Science and Engineering, Asian University of Bangladesh",
"expertise":"Databases , IT Consulting , Software Development , Front End Development",
"years":"Less than 5",
"relocation":"Schenectady, NY Within 1000 miles of 12305 Would need to relocate here",
"resume":"0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAP",
"resumeExtension":"doc",
"resumeMimeType":"application/msword"
}
]
]
下面是我的候选人简历class
public class CandidateResume
{
public string name { get; set; }
public string url { get; set; }
public string summary { get; set; }
public string role { get; set; }
public string compensation { get; set; }
public string education { get; set; }
public string expertise { get; set; }
public string years { get; set; }
public string relocation { get; set; }
public string resume { get; set; }
public string resumeExtension { get; set; }
public string resumeMimeType { get; set; }
}
错误消息:CandidateResume' 不支持反序列化数组。
你的JSON是一个列表中的列表。考虑错误 CandidateResume is not supported for deserialization of an array.
It's trying to deserialize an array to a CandidateResume
object.
改为尝试:
var myobj = jsSerializer.Deserialize<List<List<CandidateResume>>>(json);
或者将您的 JSON 更改为不是列表的列表。
在 json 中,您有额外的“[”和“]”。只需删除它们。 或者,如果它不可接受,您可以尝试
var myobj = jsSerializer.Deserialize<CandidateResume[][]>(json);