title: How to Compress a JSONObject send it over Http in Android?
body: <p>I am sending a <code>JSONObject</code> to my Webserver from an <code>Android client</code> using the code from <a href="https://stackoverflow.com/questions/3027066/how-to-send-a-json-object-over-request-with-android">this example</a>. Reproducing code here</p>
  
  <pre><code>import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.params.BasicHttpParams;
  import org.apache.http.params.HttpConnectionParams;
  import org.apache.http.params.HttpParams;
  
  int TIMEOUT_MILLISEC = 10000;  // = 10 seconds
  HttpParams httpParams = new BasicHttpParams();
  HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
  HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
  HttpClient client = new DefaultHttpClient(httpParams);
  
  HttpPost request = new HttpPost(serverUrl);
  request.setEntity(new ByteArrayEntity(
      postMessage.toString().getBytes("UTF8")));
  HttpResponse response = client.execute(request);
  </code></pre>
  
  <p><strong>My Question</strong></p>
  
  <p>How to do best compression on <code>JSONObject</code> before sending it to server and how to decompress it on Server (I am using <code>Java Servlets</code>)? </p>