title: In Ruby, how to output json from hash and give it line breaks and tabs
body: <p>I'm trying to format <code>{"key" =&gt; "value"}</code> to turn it into :</p>
  
  <pre><code>{
      "key" : "value"
  }
  </code></pre>
  
  <p>for writing into a json file.
  right now im doing :</p>
  
  <pre><code>hash = {"key" =&gt; "value"}
  puts hash.to_json.gsub('{', '{\n\t')
  </code></pre>
  
  <p>to start. and this outputs </p>
  
  <pre><code>{\n\t"key":"value"}
  </code></pre>
  
  <p>Why cant i do the line break?</p>