我具有以下功能:
function pqGrid_getData(grid)
{
debugger;
var ret = { parentData: null, childData: [] };
data = grid.option('dataModel.data'); //data of master grid.
ret.parentData = data;
for (var i = 0; i < data.length; i++) {
var rd = data[i],
dt = rd.pq_detail,
child;
if (dt && dt.child) {
//dt.child is reference to the DOM node of the child grid.
child = $(dt.child).data('pqGrid');//reference to instance of child grid.
if (child != null) {
var dataChild = child.option('dataModel.data');//data of child grid.
ret.childData.push(dataChild);
}
}
}
debugger;
return ret;
}
我正在将PQGrid的数据放入一个对象中以将其发送到服务器。
然后我将stringify()ret.childData,所以我有:
[[{"ID":"PLC0000001","Name":"CASH","ClientID":"CLN00742","Status":"1","name":"","Class":"","ClassID":"","InsuranceCardNo":"","AsAtDate":"24-07-2017","LoggedInUserName":"","ValidUntil":"24-07-2018","PayerID":"","PatientID":"","CreationDate":"","LoggedInUserID":"","Image":"","pq_cellselect":{"Name":true}}]]
但是当我尝试使用以下方法在服务器中反序列化(使用NewtonSoft)时:
List<MyObj> lstPol = JsonConvert.DeserializeObject<List<MyObj>>(jsn);
我收到以下错误:
其他信息:无法将当前JSON数组(例如[1,2,3])反序列化为类型“ MyObj”,因为该类型需要JSON 对象(例如{“ name”:“ value”})正确反序列化。
ret.ParenData运行正常。 我猜错误是chilData是一个数组,而不是普通对象,但是无法找出解决方案。谢谢