i am sending large datasets in JSON format from my android device to my server (using PHP). I want to keep bandwidth costs down. I am wondering: should I gzip compress the JSON data server side before sending the data? is there a javascript gzip uncompression library in php side and what i do in android side?
Asked
Active
Viewed 1,770 times
2
4 Answers
3
You should compress your output JSON, but you can let your php sever side script do it for you. If you use a standard compression on HTTP level the client will decompress that automatically
http://stevehanov.ca/blog/index.php?id=104
If you want to send JSON data single form than use following way
echo gzencode(json_encode($data));
josliber
- 43,000
- 12
- 95
- 132
2
You can compress your JSON output in this way from PHP server.
echo gzencode(json_encode($data));
And for android side you can use "gzip decoder"
Niharika
- 1,158
- 13
- 35
1
You can use below code
echo gzencode(json_encode($data));
Brad Larson
- 169,393
- 45
- 393
- 567
nitin jain
- 300
- 6
- 19
-
https://www.google.co.in/search?client=ubuntu&channel=fs&q=android+gzip+decode&ie=utf-8&oe=utf-8&gfe_rd=cr&ei=bHnhVJjPCOTV8geAjoCAAg – nitin jain Feb 16 '15 at 05:01
-
http://stackoverflow.com/questions/6717165/how-can-i-zip-and-unzip-a-string-using-gzipoutputstream-that-is-compatible-with – nitin jain Feb 16 '15 at 05:01
-1
You can use below for compress json
print_r(gzcompress($data));
Sasikumar Murugesan
- 4,214
- 10
- 50
- 73
Azeem Solangi
- 1
- 2
http://stackoverflow.com/questions/6717165/how-can-i-zip-and-unzip-a-string-using-gzipoutputstream-that-is-compatible-with – Jul 21 '15 at 04:53