title: What's the preferred way to dump a JSON object? to_json, JSON.generate or JSON.dump?
body: <p>I need to dump a hash object to JSON and I was wondering which of these three, <code>to_json</code>, <code>JSON.generate</code> or <code>JSON.dump</code>, is the preferred way to do it.</p>
  
  <p>I've tested the results of these methods and they are the same:</p>
  
  <pre><code>&gt; {a: 1, b: 2}.to_json
  =&gt; "{\"a\":1,\"b\":2}" 
  &gt; JSON.generate({a: 1, b: 2})
  =&gt; "{\"a\":1,\"b\":2}" 
  &gt; JSON.dump({a: 1, b: 2})
  =&gt; "{\"a\":1,\"b\":2}"
  </code></pre>