Reputation: 327
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?
Upvotes: 2
Views: 1988
Reputation: 1
You can use below for compress json
print_r(gzcompress($data));
Upvotes: -1
Reputation: 1198
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"
Upvotes: 2
Reputation:
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));
Upvotes: 3