flori/json — Issue #108: Undo "active_support/core_ext/object/to_json"
Author: kenn
Created: 2011-11-29 07:15:08+00:00
State: open

This is not really an issue but a question:

What's the suggested way to undo the effect of `active_support/core_ext/object/to_json`, that's loaded with Rails (up until) 3.1?

I'd like to use the JSON gem version of `to_json`, but it's really tricky and I wasted hours on that.

I put the following patch, but it causes `SystemStackError: stack level too deep`.

```ruby
# Undo require 'active_support/core_ext/object/to_json'
[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
klass.class_eval <<-RUBY, __FILE__, __LINE__
def to_json(options = nil)
::JSON.generate self, :quirks_mode => true
end
RUBY
end
```