title: Getting data out of a JSON Response in Rails 3
body: <p>So I am trying to pull tweets off of Twitter at put them into a rails app (Note because this is an assignment I can't use the Twitter Gem) and I am pretty confused.
  I can get the tweets I need in the form of a JSON string but I'm not sure where to go from there. I know that the Twitter API call I'm making returns a JSON array with a bunch of Tweet objects but I don't know how to get at the tweet objects. I tried JSON.parse but was still unable to get the required data out (I'm not sure what that returns). Here's the code I have so far, I've made it pretty clear with comments/strings what I'm trying for. I'm super new to Rails, so this may be way off for what I'm trying to do.</p>
  
  <pre><code>def get_tweets
  require 'net/http'
  uri = URI("http://search.twitter.com/search.json?q=%23bieber&amp;src=typd")
  
  http = Net::HTTP.new(uri.host, uri.port)
  request = Net::HTTP::Get.new(uri.request_uri)
  response = http.request(request)
  
  case response
  when Net::HTTPSuccess then #to get: text -&gt; "text", date: "created_at", tweeted by: "from_user", profile img url: "profile_img_url"
    JSON.parse(response.body)
    # Here I need to loop through the JSON array and make n tweet objects with the indicated fields
    t = Tweet.new(:name =&gt; "JSON array item i with field from_user",  :text  "JSON array item i with field text", :date =&gt; "as before" ) 
    t.save
  when Net::HTTPRedirection then
    location = response['location']
    warn "redirected to #{location}"
    fetch(location, limit - 1)
  else
    response.value
  end
  end
  </code></pre>
  
  <p>Thanks!</p>