title: JSON Array and Object into Table View with Java
body: <p>JSON looks like:</p>
  
  <pre><code>   [{"pmid":"2","name":"MANAGEMENT","result":"1","properties":[{"prop_id":"32","prop_name":" Tower","address":"281 Lakeshore","city":"Euclid","state":"OH","zip":"44142","lat":"54.5","long":"-81.5034"}]},{"pmid":"1","name":"ONE","result":"18","properties":[{"prop_id":"3","prop_name":"Chase","address":"146 Goon Blvd.","city":"City","state":"OH","zip":"12345","lat":"46.35","long":"-83.1138"},{"prop_id":"6","prop_name":"Club Apartments","address":"4600 Barrington Club","city":"Columbus","state":"OH","zip":"43520","lat":"40.436","long":"-83.048"}]}]
  </code></pre>
  
  <p>Using Android Studio, trying to retrieve with:</p>
  
  <pre><code>private static String url = "http://appurl.com/apis/pagement_list.php";
  // JSON Node names
  private static final String TAG_CONTACTS = "properties";
  private static final String TAG_NAME = "prop_id";
  private static final String TAG_EMAIL = "prop_id";
  private static final String TAG_PHONE = "prop_id";
  </code></pre>
  
  <p>After naming the nodes, I am retrieving the JSON with the following:</p>
  
  <pre><code>   @Override
      protected Void doInBackground(Void... arg0) {
          // Creating service handler class instance
          ServiceHandler sh = new ServiceHandler();
  
  
  
          // Making a request to url and getting response
          String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
          Log.d("Response: ", "&gt; " + jsonStr);
  
  
          if (jsonStr != null) {
              // We create out JSONObject from the data
              JSONObject jObj = null;
              try {
                  JSONArray mJsonArray = new JSONArray(jsonStr);
                  JSONObject mJsonObject = mJsonArray.getJSONObject(0);
  
                  String pmid = mJsonObject.getString("pmid");
                  String name = mJsonObject.getString("name");
                  String result = mJsonObject.getString("result");
  
  
                  JSONArray mJsonArrayProperty = mJsonObject.getJSONArray("properties");
                  for (int i = 0; i &lt; mJsonArrayProperty.length(); i++) {
                      JSONObject mJsonObjectProperty = mJsonArrayProperty.getJSONObject(i);
  
                      String prop_id = mJsonObjectProperty.getString("prop_id");
                      String prop_name = mJsonObjectProperty.getString("prop_name");
                      String address = mJsonObjectProperty.getString("address");
                      String city = mJsonObjectProperty.getString("city");
                      String state = mJsonObjectProperty.getString("state");
                      String zip = mJsonObjectProperty.getString("zip");
                      String lat = mJsonObjectProperty.getString("lat");
                      String lon = mJsonObjectProperty.getString("long");
  
                      // tmp hashmap for single contact
                      HashMap&lt;String, String&gt; contact = new HashMap&lt;String, String&gt;();
  
                      // adding each child node to HashMap key =&gt; value
                      contact.put(TAG_EMAIL, prop_name);
                      contact.put(TAG_NAME, name);
                      contact.put(TAG_PHONE, address);
  
  
  
  
                      // adding contact to contact list
                      contactList.add(contact);
                  }
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
          }
              else {
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
  
              return null;
          }
      @Override
      protected void onPostExecute(Void result) {
          super.onPostExecute(result);
  
  
          // Dismiss the progress dialog
          if (pDialog.isShowing())
              pDialog.dismiss();
          /**
           * Updating parsed JSON data into ListView
           * */
          ListAdapter adapter = new SimpleAdapter(
                  MainActivity.this, contactList,
                  R.layout.list_item, new String[] { TAG_NAME, TAG_EMAIL, TAG_PHONE}, new int[] { R.id.name,
                  R.id.email, R.id.mobile});
  
          setListAdapter(adapter);
  
  
      }
  
  }
  </code></pre>
  
  <p>I am able to successfully retrieve into the TableView the first Array, Tower, with Lakeshore Address. But, I do not know how to get to the other pieces of JSON, the other name, for instance. </p>
  
  <p>It would be great if the name could be displayed right before the array including prop_name. And the name only needs to be displayed once, in the case there are multiple prop_name under it. </p>