Action results encoded using JsonResult
seem to be excessively verbose in their serialisation. For example:
{"foo":"bar","list":["a","b"],"map":{"a":1,"b":2,"c":3}}
JavaScript seems perfectly happy with this shorter version as an equivalent:
{foo:"bar",list:["a","b"],map:{a:1,b:2,c:3}}
So this question is two-fold:
Is there a reason that the former is better, assuming all my labels are valid JavaScript identifiers?- Can I force the ASP.NET MVC framework to encode my messages using this shorter syntax?
I'm writing quite an AJAX-heavy app and have calculated that I'd save between 15% and 20% on message size. In many cases it will be the difference between fitting the response in a single TCP packet or not. Even disregarding performance, a reduction of that much in terms of my monthly bandwidth bill would be a boon.
EDIT
As Justin points out, the quotes are needed according to the JSON standard, but I don't need them in a browser for pure JavaScript use. Can I force the .NET web framework to drop the quotes in some fashion that's simpler than writing my own JSON serialiser?