How can i create a json array like this in ashx handler:
{
"sEcho": 1,
"iTotalRecords": "57",
"iTotalDisplayRecords": "57",
"aaData":
[
[ "Gecko", "Firefox 1.0", "Win 98+ / OSX.2+", "1.7", "A" ]
]
}
Build it as anonymous object in dotnet and then serialize it as Json, Asp.Net has the serializer built in.
string json = context.Response.Write(Json(new {
sEcho = 1,
iTotalRecords = "57",
iTotalDisplayRecords = "57",
aaData = new List<List<String>>
{ new List<String>{ "Gecko", "Firefox 1.0", "Win 98+ / OSX.2+", "1.7", "A" }}
}, JsonRequestBehavior.AllowGet));
Update:
Modified based on comments.
>`, or similar)
– Tim S. Nov 30 '13 at 20:16