title: Looping and converting JSON Object to Array
body: <p>I'm new to Java and programming for Android and I've seen a lot of tutorials but I am kinda clueless atm on how to loop through a JSONObject and set it to my class.</p>
  
  <p>Example of JSON data:
  <a href="http://sickbeard.com/api/#history" rel="nofollow">http://sickbeard.com/api/#history</a></p>
  
  <p>Class I made:</p>
  
  <pre><code>public Episode(JSONObject obj) {
          try {
              this.id =   Integer.parseInt(obj.getString("episode").toString());
              this.tvId = Integer.parseInt(obj.getString("tvdbid").toString());
              this.resource = obj.getString("resource").toString();
          } catch (NumberFormatException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>I came as far as this...</p>
  
  <pre><code>ArrayList&lt;Episode&gt; episodeList = new ArrayList&lt;Episode&gt;();
              JSONObject data = new JSONObject();
              for(int i = 0; i &lt; 2; i++) {
                  try {
                      data = response.getJSONObject("data");
                      episodeList.add(new Episode(data));
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
              return null;
              // for each entry create new episode :)
          } else {
              return null;
          }
  </code></pre>