[英]class is not supported for deserialization of an array
我有以下有效的JSON
{
"payrollInformation":[ {"EmployeeId":"19","FirstName":"Rebecca","LastName":"Smith","IsHourly":"false","PayFrequency":"102","Amount":"2000","StandardHours":"40","PayGroup":"null","Year":"2013","Sequence":"3","RegularHours":"4","OTHours":"5","DOTHours":"0","Earning":"775","Deduction":"40","RegularHoursIncome":"2000","OverTimeHoursIncome":"15000","DoubleOverTimeHoursIncome":"0","GrossPay":"8775"},{"EmployeeId":"20","FirstName":"Jason","LastName":"Florence","IsHourly":"true","PayFrequency":"0","Amount":"50","StandardHours":"40","PayGroup":"null","Year":"2013","Sequence":"1","RegularHours":"8","OTHours":"4","DOTHours":"0","Earning":"100","Deduction":"115","RegularHoursIncome":"400","OverTimeHoursIncome":"300","DoubleOverTimeHoursIncome":"0","GrossPay":"800"},{"EmployeeId":"21","FirstName":"Peter","LastName":"Schepcozki","IsHourly":"true","PayFrequency":"0","Amount":"50","StandardHours":"40","PayGroup":"null","Year":"2013","Sequence":"1","RegularHours":"6","OTHours":"0","DOTHours":"0","Earning":"525","Deduction":"10","RegularHoursIncome":"300","OverTimeHoursIncome":"0","DoubleOverTimeHoursIncome":"0","GrossPay":"825"},{"EmployeeId":"22","FirstName":"Anita","LastName":"Stone","IsHourly":"true","PayFrequency":"0","Amount":"100","StandardHours":"40","PayGroup":"null","Year":"2013","Sequence":"1","RegularHours":"7","OTHours":"0","DOTHours":"0","Earning":"0","Deduction":"10","RegularHoursIncome":"700","OverTimeHoursIncome":"0","DoubleOverTimeHoursIncome":"0","GrossPay":"700"},{"EmployeeId":"23","FirstName":"John","LastName":"Smith","IsHourly":"true","PayFrequency":"0","Amount":"55","StandardHours":"40","PayGroup":"null","Year":"2013","Sequence":"1","RegularHours":"8","OTHours":"3","DOTHours":"0","Earning":"100","Deduction":"25","RegularHoursIncome":"440","OverTimeHoursIncome":"247.5","DoubleOverTimeHoursIncome":"0","GrossPay":"787.5"},{"EmployeeId":"24","FirstName":"Rachel","LastName":"Crew","IsHourly":"true","PayFrequency":"0","Amount":"69","StandardHours":"40","PayGroup":"null","Year":"2013","Sequence":"1","RegularHours":"4","OTHours":"0","DOTHours":"0","Earning":"150","Deduction":"106","RegularHoursIncome":"276","OverTimeHoursIncome":"0","DoubleOverTimeHoursIncome":"0","GrossPay":"426"}
]
}
當我嘗試在我的網絡方法中將此信息作為參數傳遞時,出現以下錯誤
數組反序列化不支持該類
這是我的網絡方法的簽名
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static bool CalculateTaxes(PayCheckInfoJSON payrollInformation)
{
我已經在我的js中聲明payrollInformation
如下
var PayCheckInfo = { data: [] };
並按如下方式在js中推送項目
PayCheckInfo.data.push({
"EmployeeId": EmployeeId,
"FirstName": FirstName,
"LastName": LastName,
"IsHourly": IsHourly,
"PayFrequency": PayFrequency,
"Amount": Amount,
"StandardHours": StandardHours,
"PayGroup": PayGroup,
"Year": Year,
"Sequence": Sequence,
"RegularHours": RegularHours,
"OTHours": OTHours,
"DOTHours": DOTHours,
"Earning": Earning,
"Deduction": Deduction,
"RegularHoursIncome": RegularHoursIncome,
"OverTimeHoursIncome": OverTimeHoursIncome,
"DoubleOverTimeHoursIncome": DoubleOverTimeHoursIncome,
"GrossPay": GrossPay
});
將您的C#類標記為:
[serializable]
public class PayCheckInfoJSON
{}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.