title: How do I read JSON received from a REST API?
body: <p>I'm trying to read some JSON that I received from a REST API but I'm having some issues.</p>
  
  <p>To get my JSON, I'm using Open::URI. I created my request like this:</p>
  
  <pre><code>require "open-uri"
  require "json"
  content = open("http://foo.bar/test.json").read
  result = JSON.parse(content)
  </code></pre>
  
  <p>At this point my JSON is supposed to be parsed from a string, and so if I correctly understood, a hash containing my JSON is built assuming the JSON I received has a structure that looks like this:</p>
  
  <pre><code>{
     "root":
     {
         "foos":
         {
             "1":
             {
                 "title" : "zero",
                 "number" : 0
             },
             "2":
             {
                 "title" : "twenty",
                 "number" : 20
             },
             ...
         }
      }
  }
  </code></pre>
  
  <p>I would like to iterate over each <code>foos</code> and, for each of them, get the title and the number. I tried this:</p>
  
  <pre><code>content["root"]["foos"].each do |foo| puts foo.title + " " + foo.number end
  </code></pre>
  
  <p>But, as output, I got:</p>
  
  <pre><code>#&lt;Enumerator:0x007fceb8b33718&gt;
  </code></pre>
  
  <p>Where is/are my mistake(s)?</p>
  
  <p>Thanks in advance,</p>