How to write to a JSON file in the correct format
Require the JSON library, and use to_json. require ‘json’ tempHash = { “key_a” => “val_a”, “key_b” => “val_b” } File.open(“public/temp.json”,”w”) do |f| f.write(tempHash.to_json) end Your temp.json file now looks like: {“key_a”:”val_a”,”key_b”:”val_b”}