【发布时间】:2013-12-11 20:16:59
【问题描述】:
您好,我有以下类型的 json 对象,在来自 android 的一个请求中上传了很多文件和内容,图片数量可能会有所不同,并且可能比以下示例更多。示例中还有很多其他小键值,例如地址、电话等
{
"pdf": "base64stringvalue",
"name": "username",
"picture": "base64string",
"picture1": "base64string",
"picture2": "base64string",
"picture3": "base64string",
"picture4": "base64string",
"picture5": "base64string",
"picture6": "base64string",
"picture7": "base64string",
"picture8": "base64string",
"picture9": "base64string"
}
我想 gZip 对象并且想知道这样做的最佳方法是什么,基于使用 gzip 资源一次(a)和多次(b)
(a)我应该在客户端上压缩整个 json 对象并在服务器上解压缩它
{"object":"gzipped(wholeObject)"}
(b) 我是否应该只压缩对象中的 base64string 值(基本上分别压缩和解压缩每个实体)和类似的东西
{
"pdf": "gzipped(base64string)",
"name": "username",
"picture": "gzipped(base64string)",
"picture1": "gzipped(base64string)",
"picture2": "gzipped(base64string)",
"picture3": "gzipped(base64string)",
"picture4": "gzipped(base64string)",
"picture5": "gzipped(base64string)",
"picture6": "gzipped(base64string)",
"picture7": "gzipped(base64string)",
"picture8": "gzipped(base64string)",
"picture9": "gzipped(base64string)"
}
【问题讨论】:
-
什么你不压缩它在 HTTP 级别。只需将您的数据压缩后发布即可。