title: Sending JSON from Android to PHP Server
body: <p>Hi every body i have sending a JSON object to php server  .my json is as below-</p>
  
  <pre><code>        {"cart_detail":{"product_id":"66922","ref_id":"chand09","user_id":"1"}}
  </code></pre>
  
  <p>I am sending JSON by below code-</p>
  
  <pre><code>      public void postData(String result,JSONObject obj) {
      // Create a new HttpClient and Post Header
      HttpClient httpclient = new DefaultHttpClient();
      HttpParams myParams = new BasicHttpParams();
      HttpConnectionParams.setConnectionTimeout(myParams, 10000);
      HttpConnectionParams.setSoTimeout(myParams, 10000);
      System.out.println(" before JSON string");
      String json=obj.toString();
  
      try {
  
          HttpPost httppost = new HttpPost(result.toString());
          httppost.setHeader("Content-type", "application/json");
          System.out.println("After httpost header");
          StringEntity se = new StringEntity(obj.toString());   
          System.out.println(" sending json string"+se);
          se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
          httppost.setEntity(se); 
  
          HttpResponse response = httpclient.execute(httppost);
          HttpEntity entity = response.getEntity();
  
          String temp = EntityUtils.toString(response.getEntity());
  
            System.out.println(" i am getting response entity "+entity);
  
  
          Log.i("tag", temp);
          System.out.println(" item send sucessfully to cart by server");
  
      } catch (ClientProtocolException e) {
  
      } catch (IOException e) {
      }
  }
  </code></pre>
  
  <p>My PHP to handle the response is as-</p>
  
  <pre><code>      $data = array("cart_details" =&gt; array($_REQUEST));
         echo "&lt;pre&gt;";
         print_r($data);
         echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>In response i am getting stack-Trace is as follow-</p>
  
  <pre><code>    07-26 14:57:45.124: I/System.out(7191):  i am getting response entity org.apache.http.conn.BasicManagedEntity@405d2fd0
      07-26 14:57:45.124: I/System.out(7191):  i am getting response string org.apache.http.impl.client.ClientParamsStack@405134a8
     07-26 14:57:45.124: I/tag(7191): &lt;pre&gt;Array
     07-26 14:57:45.124: I/tag(7191): (
     07-26 14:57:45.124: I/tag(7191):     [cart_details] =&gt; Array
     07-26 14:57:45.124: I/tag(7191):         (
    07-26 14:57:45.124: I/tag(7191):             [0] =&gt; Array
    07-26 14:57:45.124: I/tag(7191):                 (
    07-26 14:57:45.124: I/tag(7191):                 )
     07-26 14:57:45.124: I/tag(7191):         )
     07-26 14:57:45.124: I/tag(7191): )
     07-26 14:57:45.124: I/tag(7191): &lt;/pre&gt;
    07-26 14:57:45.124: I/System.out(7191):  item send sucessfully to cart by server
  </code></pre>
  
  <p>I did not know what  problem is going on. I am new for json. How i will check that my request is going or not. In response i am receiving same json , but why this json is empty? Is it fault of android part or PHP Server .Thanks in advance to all. </p>