Rails 2.3’s JSON Serializer Was a Broken Hack
Rails 2.3 made a questionable engineering call: it shipped its own pure-Ruby JSON serializer instead of leaning on the existing C-extension gem, which was already available and roughly 20 times faster. The bigger problem, though, was the method signature. The to_json method that Rails added—via a monkeypatch that hits every object—was completely incompatible with the standard gem’s version. You couldn’t mix the two, which turned into a real headache for anyone trying to push more than 10 requests per second.
And the output wasn’t just slow—it was sometimes flat-out wrong. Consider this example:
puts {:rails => /fail/x}.to_json #=> {"rails" => /fail/x}
That’s broken on two counts. It’s not valid ECMAScript, and it’s certainly not valid JSON by the RFC standard. The worst part was that you couldn’t opt out: requiring ActiveSupport forced this broken patch onto every object in your app. The good news? The Rails team eventually fixed the problem in a later release.



