I\'m trying to format {\"key\" => \"value\"} to turn it into :
{
\"key\" : \"value\"
}
for writing into a json file. ri
For both line breaks and tabs, try
require 'json'
hash = {foo: 'bar'}
JSON.pretty_generate(hash, {indent: "\t", object_nl: "\n"})
NB! If you use single quotes with newlines ("\n") or tabs ("\t") they will not be interpreted as newlines but as an ordinary string containing one backslash and a letter. This is a common mistake. :)