title: How do you deal with the conflict between ActiveSupport::JSON and the JSON gem?
body: <p>I am stumped with this problem.</p>
  
  <p><code>ActiveSupport::JSON</code> defines <code>to_json</code> on various core objects and so does the JSON gem. However, the implementation is not the same -- the ActiveSupport version takes arguments and the JSON gem version doesn't.</p>
  
  <p>I installed a gem that required the JSON gem and my app broke. The issue is that I'm using <code>to_json</code> in a controller that returns a list of objects, but I want to control which attributes are returned. </p>
  
  <p>When code anywhere in my system does <code>require 'json'</code> I get this error message: </p>
  
  <p><code>TypeError: wrong argument type Hash (expected Data)</code></p>
  
  <p>I tried a couple of things that I read online to fix it, but nothing worked. I ended up re-writing the gem to use <code>ActiveSupport::JSON.decode</code> instead of <code>JSON.parse</code>.</p>
  
  <p>This works but it's not sustainable...I can't be forking gems every time I want to use a gem that requires the JSON gem.</p>
  
  <p><strong>Update:</strong> The best solution of this problem is to upgrade to Rails 2.3 or higher, which fixed it.</p>