I have a WebMethod that looks like that used to populate jqGrid
[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;
}
}
"results" is a System.Dynamic.ExpandoObject with properties Items, TotalPages, TotalRecords
json I'm going back to the web service what it looks like
{
"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"
}]
]
}]
}
}
Ideally, I would prefer that he come back without any Key and Value business, as he over-inflates json and doesn't play well with jqGrid.
Is there a way to change the way ASP.NET expandoObject serialization is handled?