且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

普通表单提交与JSON

更新时间:2022-10-31 14:00:08

处理POST数据时想到的一件事是无用的重复:

One thing comes to mind when dealing with POST data is useless repetition:

例如,在POST中,我们有以下内容:

For example, in POST we have this:

partners[]=Apple&partners[]=Microsoft&partners[]=Activision

我们实际上可以看到,这里有很多重复,就像我们发送JSON时一样:

We can actually see, that there is a lot of repetition here, where as when we are sending JSON:

{"partners":["Apple","Microsoft","Activision"]}

59个字符对47个字符.在这个小样本中,它看起来微不足道,但是这些节省可能会不断增加,甚至几个字节也可以为您节省一些数据.当然,在服务器端可以进行数据解析,甚至可以消除差异,但是,在处理较慢的连接(查看您,3G和EDGE)时,我仍然看到有时这会有所帮助.

59 characters versus 47. In this small sample it looks miniscule, but these savings could go up and up, and even several bytes will save you some data. Of course, there is the parsing of data on server side, which could even out the differences, but still, i saw this sometimes helping when dealing with slower connections (looking at you, 3G and EDGE).