title: HTTPArty/Rails: How to handle the Response array
body: <p>I am calling an API that returns an array of JSON objects and I cant seem to properly access each element. This is a sample return value of the API call</p>
  
  <pre><code>[{"param1":1,"param2":"blah1"},
  {"param1":2,"param2":"blah2"},
  {"param1":3,"param2":"blah3"}]
  </code></pre>
  
  <p>Here is me trying to call the API and print the first JSON response object's parameter</p>
  
  <pre><code>result = HTTParty.get('http://randomapi.com',query: options)
  @a = result[0]['param1']
  # puts "#{result}"
  puts "#{@a}"
  </code></pre>
  
  <p>Doing this prints nothing. I know I am successfully accessing the URL because result will print the correct information.</p>
  
  <p>I got information on how to access the JSON response through this URL
  <a href="http://blog.teamtreehouse.com/its-time-to-httparty" rel="nofollow">http://blog.teamtreehouse.com/its-time-to-httparty</a></p>
  
  <p><strong>Edit</strong>:
  After reading comments below, I realized that the API call is returning a content type of text/html and parsing the text/html isnt working because the response is also returning the following header below the expected value. Is there any way to remove this without going into the string itself and stripping it out?</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html 
      xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form method="post" action="GetRankingList.aspx?pvptype=1&amp;amp;sid=1&amp;amp;tm=20130821160000&amp;amp;auth=77c9b582c3aed3d3974400cfb118fe4b" id="form1"&gt;
              &lt;div class="aspNetHidden"&gt;
                  &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZLSAAAtd4/lj1u6b0GjPWM+p3i9tqI6sq+xDrRw2cAv3" /&gt;
              &lt;/div&gt;
              &lt;div&gt;&lt;/div&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>