jqGridにデータを入力するために使用されるこのようなWebMethodがあります
[System.Web.Script.Services.ScriptService]
public class MyWebService: System.Web.Services.WebService
{
[WebMethod]
[Authorize(Roles = "Admin")]
public object GetPeople(bool _search, double nd, int rows, int page, string sidx, string sord)
{
var tbl = new DynamicModel("ConnStr", tableName: "Person", primaryKeyField: "ID");
var results = tbl.Paged(orderBy: sidx + " " + sord, currentPage: page, pageSize: rows);
return results;
}
}
「結果」は、プロパティItems、TotalPages、TotalRecordsを持つSystem.Dynamic.ExpandoObjectです。
Webサービスから戻ってきたjsonは次のようになります
{
"d": [{
"Key": "TotalRecords",
"Value": 1
}, {
"Key": "TotalPages",
"Value": 1
}, {
"Key": "Items",
"Value": [
[{
"Key": "Row",
"Value": 1
}, {
"Key": "ID",
"Value": 1
}, {
"Key": "Name",
"Value": "Test Template"
}]
]
}]
}
} // Don't know why firebug put this extra bracket
理想的には、jsonを不必要に膨らませ、jqGridでうまく機能しないため、すべてのKeyandValueビジネスなしで戻ってくることを望んでいます。
ASP.NETがExpandoObjectのシリアル化を処理する方法を変更する方法はありますか?