title: How to write to a JSON file in the correct format
body: <p>I am creating a hash in Ruby and want to write it to a JSON file, in the correct format.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>tempHash = {
      "key_a" =&gt; "val_a",
      "key_b" =&gt; "val_b"
  }
  fJson = File.open("public/temp.json","w")
  fJson.write(tempHash)
  fJson.close
  </code></pre>
  
  <p>And here is the contents of the resulting file:  </p>
  
  <pre><code>key_aval_akey_bval_b
  </code></pre>
  
  <p>I'm using Sinatra (don't know what version) and Ruby v 1.8.7.</p>
  
  <p>How can I write this to the file in the correct JSON format?  </p>