Q:

How to print hash data as { label: "Chrome", data: 2 } in Rails

Now my hash data is print as 
{ :label=> "Chrome", :data=> 2}
but i want to print it as 
{ label: "Chrome", data: 2}
How to make it work? 

A:

If you don't mind quotation marks around keys use to_json
puts hash.to_json

If you do, nothing better comes to my mind than:
puts "{" + hash.map{|k,v| "#{k}: #{v.to_json}"}.join(', ') + "}"

