title: pass list<object> from android to php in json format using URLConnection
body: <p>I am trying to send 2 variables(mobile_no,group_id) and 1 list of JSONObject with name &amp; number arguments.
  Somehow I am able to display mobile_no,group_id in toast but cannot display any value from the list objects. Instead i get some error: PHP Error Message</p>
  
  <p>Here is my code:</p>
  
  <pre><code>      private Context context;
  
  public SendJsonObject(Context context) {
      this.context = context;
  }
  
  @Override
  protected String doInBackground(String... params) {
      URL url;
      URLConnection urlConn;
      DataOutputStream printout;
  
      try {
          url = new URL (php_url);
  
          urlConn = url.openConnection();
          urlConn.setDoInput(true);
          urlConn.setDoOutput(true);
          urlConn.setUseCaches(false);
          urlConn.setRequestProperty("Content-Type","application/json");
          urlConn.connect();
  //Create JSONObject here
  
          List&lt;JSONObject&gt; mylist=new ArrayList&lt;&gt;();
  
          JSONObject contacts=new JSONObject();
          contacts.put("name","ABC");
          contacts.put("number","9999999999");
          mylist.add(contacts);
  
  
          JSONObject jsonParam = new JSONObject();
          jsonParam.put("mobile_no", "998888888");
          jsonParam.put("group_id", "11");
          jsonParam.put("mylist", mylist);
  
          printout=new DataOutputStream(urlConn.getOutputStream());
          printout.writeBytes(jsonParam.toString());
          printout.flush();
          printout.close();
  
          BufferedReader reader=new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
          String response= reader.readLine();
  
  
          String name=response.substring(3);
          return response;
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (JSONException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return null;
  }
  
  protected void onPostExecute(String response) {
  
      Toast.makeText(context, response, Toast.LENGTH_LONG).show();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>And this is my php code :</p>
  
  <pre><code>&lt;?php
  
   $json = file_get_contents('php://input');
   $data = json_decode($json, true);
  
   echo $data['mobile_no'];
   echo $data['group_id'];
   echo $data['mylist'][0]['name']; 
  
   ?&gt;
  </code></pre>
  
  <p>Please help me on this guys,would really appreciate it .....</p>