I have a WebMethod that looks like this which is used to populate a 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 the properties Items, TotalPages, TotalRecords
The json I get back on the from the webservice looks like this
{
"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
Ideally I'd prefer that it comes back without all the Key and Value business as it bloats out the json unnecessarily and doesn't play nicely with jqGrid.
Is there a way to change the way ASP.NET is handling the serialization of the ExpandoObject?