title: Ruby - iterate over parsed JSON
body: <p>I'm trying to iterate of a parsed JSON response from reddit's API.</p>
  
  <p>I've done some googling and seems others have had this issue but none of the solutions seem to work for me. Ruby is treating ['data]['children] as indexes and that's causing the error but I'm just trying to grab these values from the JSON. Any advice?</p>
  
  <p>My code:</p>
  
  <pre><code>require "net/http"
  require "uri"
  require "json"
  
  uri = URI.parse("http://www.reddit.com/user/brain_poop/comments/.json")
  
  response = Net::HTTP.get_response(uri)
  
  data = JSON.parse(response.body)
  
  data.each do |child|
      print child['data']['body']
  end
  </code></pre>
  
  <p>The error message I get in terminal:</p>
  
  <pre><code>api-reddit-ruby.rb:12:in `[]': no implicit conversion of String into Integer (TypeError)
  from api-reddit-ruby.rb:12:in `block in &lt;main&gt;'
  from api-reddit-ruby.rb:11:in `each'
  from api-reddit-ruby.rb:11:in `&lt;main&gt;'
  </code></pre>