TypeError while iterating through a Hash
- by Ved
I have the following hash:
{"groups"=>[{"type"=>"Nearby", "venues"=>[{"id"=>4450132, "name"=>"Position2", "address"=>"Domlur", "city"=>"Bangalore", "state"=>"Karnataka/India", "zip"=>"560037", "verified"=>false, "geolat"=>12.9566921, "geolong"=>77.6407258, "stats"=>{"herenow"=>"0"}, "twitter"=>"position2", "hasTodo"=>"false", "distance"=>0},...
I want to iterate through it and find all the 'name' attributes. My code looks like:
response["groups"]["Nearby"]["venues"].each do |key|
logger.debug key['name']
end
But I keep on getting error:
TypeError (can't convert String into Integer):
I am on ruby 1.9.