简体   繁体   English

在AJAX请求/响应中压缩/缩小JSON

[英]Compress/Minify JSON in AJAX requests/responses

I was checking out some of the code on Facebook, specifically the headers of the AJAX requests/responses and noticed that they seem to be compress/minified just like one would do with CSS or JavaScript. 我在Facebook上检查了一些代码,特别是AJAX请求/响应的标头,并注意到它们似乎像CSS或JavaScript一样被压缩/最小化。

This would turn 这将变成

{ id: 1000, username: "testing" }

Turns into this: 变成这样:

{a:1000,b:"testing"}

Is this possible with ASP.NET MVC in any way? ASP.NET MVC是否可以通过任何方式实现? I'd like to explore this idea and wondered if there was some special model binding technique that could be used? 我想探索这个想法,想知道是否可以使用某些特殊的模型绑定技术?

I think Custom Binding is the way to go. 我认为自定义绑定是必经之路。
Here is a good brief explanation. 是一个很好的简短说明。

--- more detail --- - - 更多详情 - -
you can intercept binding json data shipped by QueryString and convert received json into desired model. 您可以拦截QueryString绑定json数据,并将接收到的json转换为所需的模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM