I have two questions for you regarding the json support in Rails.
Looking in “activesupport-2.3.5/lib/active_support/json/encoding.rb” I
find this comment:
Hack to load json gem first so we can overwrite its to_json.
Why would the author want to overwrite the json gem’s to_json methods if
I’ve explicitly defined that I want to use the json gem as backend? The
json gem is much faster than Rails’ own!
And how can I setup my environment to use the json gem for encoding?
Setting this:
ActiveSupport::JSON.backend = “JSONGem”
… doesn’t affect encoding as the to_json methods are still overwritten
(as far as I can see).
I’ve also tried calling “JSON.fast_generate” directly on the json gem,
but as this method uses the to_json methods (which have been overwritten
by Rails) this has no effect.
which was only recently fixed. I would rather use the json gem than wait
for Rails to find all the bugs and improve the speed of the home-grown
json implementation.
which was only recently fixed. I would rather use the json gem than wait
for Rails to find all the bugs and improve the speed of the home-grown
json implementation.
Any help?
I circumvented the Rails hack by making a hack of my own.
Hopefully, the Rails core team does not create more hacks of this
nature. Better yet, the hack should be removed. I want to choose which
version of to_json I use (instead of some Rails core dude).
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.