title: Putting JSON data into a List
body: <p>I have my JSON data coming correctly from my server, I just want to put it into the following array but I'm not sure the JSON data is correctly being inserted into the ArrayList. </p>
  
  <p>Here is the array</p>
  
  <pre><code>private List&lt;ShopInfo&gt; createList(int size)  {
      List&lt;ShopInfo&gt; result = new ArrayList&lt;ShopInfo&gt;();
      for (int i = 1; i &lt;= size; i++) {
          ShopInfo ci = new ShopInfo();
          ci.name =    TAG_NAME+i;
          ci.address = TAG_ADDRESS+i;
          result.add(ci);
      }
      return result;
  }
  </code></pre>
  
  <p>My json</p>
  
  <pre><code>{"success":1,"shops":[{"name":"Test_Shop","address":"1 Big Road Dublin"}
  </code></pre>
  
  <p>The file </p>
  
  <pre><code>public class OrderCoffee extends Activity {
  
  JSONParser jParser = new JSONParser();
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; shopList;
  private static String url_all_products = "xxxxxxxxxx/ordercoffee.php";
  // products JSONArray
  JSONArray shops = null;
  
  
  // JSON Node names
  private static final String TAG_SUCCESS = "success";
  private static final String TAG_SHOPS = "shops";
  private static final String TAG_NAME = "name";
  private static final String TAG_ADDRESS = "address";
  
  
  //get a list of participating coffee shops in the locality that are using the app
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.order_coffee);
      new LoadAllProducts().execute();
      RecyclerView recList = (RecyclerView) findViewById(R.id.cardList);
      recList.setHasFixedSize(true);
      LinearLayoutManager llm = new LinearLayoutManager(this);
      llm.setOrientation(LinearLayoutManager.VERTICAL);
      recList.setLayoutManager(llm);
      shopList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      ShopAdapter ca = new ShopAdapter(createList(3));
      recList.setAdapter(ca);
  
  }
  
  
  class LoadAllProducts extends AsyncTask&lt;String, String, String&gt; {
  
  
      @Override
      protected String doInBackground(String... args) {
          // Building Parameters
          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
          // getting JSON string from URL
          JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);
  
          // Check your log cat for JSON reponse
          Log.d("All Products: ", json.toString());
  
          try {
              // Checking for SUCCESS TAG
              int success = json.getInt(TAG_SUCCESS);
  
              if (success == 1) {
                  // products found
                  // Getting Array
                  shops = json.getJSONArray(TAG_SHOPS);
  
                  // looping through All Products
                  for (int i = 0; i &lt; shops.length(); i++) {
                      JSONObject c = shops.getJSONObject(i);
  
                      // Storing each json item in variable
                      String id = c.getString(TAG_ADDRESS);
                      String name = c.getString(TAG_NAME);
  
                      // creating new HashMap
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      // adding each child node to HashMap key =&gt; value
                      map.put(TAG_ADDRESS, id);
                      map.put(TAG_NAME, name);
  
                      shopList.add(map);
  
  
                  }
              } else {
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          return null;
      }
  
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  
  
  private List&lt;ShopInfo&gt; createList(int size)  {
      List&lt;ShopInfo&gt; result = new ArrayList&lt;ShopInfo&gt;();
      for (int i = 1; i &lt;= size; i++) {
          ShopInfo ci = new ShopInfo();
          ci.name =    TAG_NAME+i;
          ci.address = TAG_ADDRESS+i;
          result.add(ci);
      }
      return result;
  }
  }
  </code></pre>
  
  <p>ShopAdapter</p>
  
  <pre><code>  package com.example.strobe.coffeetime;
  
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  
  import java.util.List;
  
  /**
   * Created by root on 10/04/15.
   */
  public class ShopAdapter extends RecyclerView.Adapter&lt;ShopAdapter.ShopViewHolder&gt; {
  
      private List&lt;ShopInfo&gt; shopList;
  
      public ShopAdapter(List&lt;ShopInfo&gt; shopList) {
          this.shopList = shopList;
      }
  
  
      @Override
      public int getItemCount() {
          return shopList.size();
      }
  
      @Override
      public void onBindViewHolder(ShopViewHolder shopViewHolder, int i) {
          ShopInfo ci = shopList.get(i);
          shopViewHolder.vName.setText(ci.name);
          shopViewHolder.vAddress.setText(ci.address);
  
      }
  
      @Override
      public ShopViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
          View itemView = LayoutInflater.
                  from(viewGroup.getContext()).
                  inflate(R.layout.card_layout, viewGroup, false);
  
          return new ShopViewHolder(itemView);
      }
  
      public static class ShopViewHolder extends RecyclerView.ViewHolder {
  
          protected TextView vName;
          protected TextView vAddress;
  
  
          public ShopViewHolder(View v) {
              super(v);
              vName =  (TextView) v.findViewById(R.id.name);
              vAddress = (TextView)  v.findViewById(R.id.address);
  
          }
      }
  }
  </code></pre>