title: How to convert a ruby hash object to JSON?
body: <p>How to convert a ruby hash object to JSON? So I am trying this example below &amp; it doesn't work?</p>
  
  <p>I was looking at the RubyDoc and obviously <code>Hash</code> object doesn't have a <code>to_json</code> method. But I am reading on blogs that Rails supports <code>active_record.to_json</code> and also supports <code>hash#to_json</code>. I can understand <code>ActiveRecord</code> is a Rails object, but <code>Hash</code> is not native to Rails, it's a pure Ruby object. So in Rails you can do a <code>hash.to_json</code>, but not in pure Ruby??</p>
  
  <pre><code>car = {:make =&gt; "bmw", :year =&gt; "2003"}
  car.to_json
  </code></pre>