title: Convert nested array to JSON
body: <p>This code:</p>
  
  <pre><code>@countries.map { |l| [l.country_name, l.latitude, l.longitude, l.capital] }
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>[["country_name_1", latitude, longitude, capital],["country_name_2", latitude, longitude, capital],...]
  </code></pre>
  
  <p>But I need to convert to JSON; something like this:</p>
  
  <pre><code>{
     "country_name_1" : [latitude, longitude, "capital"],
     "country_name_2" : [latitude, longitude, "capital"],
     .
     .
     .
  }
  </code></pre>