How to convert a ruby hash object to JSON? So I am trying this example below & it doesn\'t work?
I was looking at the RubyDoc and obviously Hash obj
Hash
Add the following line on the top of your file
require 'json'
Then you can use:
car = {:make => "bmw", :year => "2003"} car.to_json
Alternatively, you can use:
JSON.generate({:make => "bmw", :year => "2003"})