New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace multi_json with json #10576
Replace multi_json with json #10576
Conversation
👍 for killing multi_json |
👍 |
🤘 |
* master: (61 commits) add tests for reset_calbacks Fixing build broken by this change Extract variable out of loop Updated comment to Rails 4 Fixes NoMethodError: `alias_method_chain` when requiring just active_support/core_ext better error message when app name is not passed in `rails new` Code cleanup for ActionDispatch::Flash#call Fix typo: require -> requires Add CHANGELOG entry for #10576 Merge pull request #10556 from Empact/deprecate-schema-statements-distinct Some editorial changes on the documentation. respond_to -> respond to in a message from AM::Lint specify that dom_(id|class) are deprecated in controllers, views are fine copy edits [ci skip] Fix class and method name typos Replace multi_json with json ruby -> Ruby Adding documentation to the automatic inverse_of finder. Improve CHANGELOG entry [ci kip] Call assume_migrated_upto_version on connection ... Conflicts: activesupport/lib/active_support/callbacks.rb
Is it too late to get this backported to 4-0-stable? Btw, love your approach, @sferik |
What about oj and yajl support? |
Not to speak for @teamon, but I think the problem is there are JSON documents that the json library cannot or will not parse. In these cases, using an alternative JSON processor is necessary. While those libraries certainly can be used directly, this change will break existing uses of ActiveSupport's JSON processing that have worked fine since the 2.x days. If swapping out JSON processors isn't going to be possible, there should probably be a caveat in the upgrade guide that this could break existing apps. |
@nirvdrum If there are JSON documents that are legal according to the JSON spec that |
@charliesome Some it cannot parse because its architecture fundamentally doesn't support. E.g., docs of certain sizes will blow out memory in That aside, even if it could subsume all other JSON processors in some future release, then you'd have to require a version not bundled with stdlib anyway, kinda negating the purported benefit of this being bundled in stdlib. |
@nirvdrum That's a fair point, I hadn't considered that. It seems to me that large documents requiring a 'SAJ' (is that a thing?) parser are probably out of scope of what Rails should handle for you, given that it's likely you'll need to work with them specially anyway. |
I think if you know from the outset that's a limitation, it's a fair point. The way I've seen it happen is a bunch of code is already using ActiveSupport's JSON interface, a problematic doc comes along, and then the engine is swapped out. Regardless of the rationale, the point I was raising is that |
But I want to use OJ for performance reasons how do I go about that now? |
I'd also like to use a different JSON library than Ruby's default, within Rails. For the moment, I'm working on an API, built with Rails 4 and |
Since Rails 4 will require Ruby 1.9 and since Ruby 1.9 includes
json
in the standard library,multi_json
is no longer necessary. I am a longtime maintainer ofmulti_json
but will stop supporting the library in June.This patch replaces
multi_json
with stdlibjson
. It will use thejson
gem if a newer version is available.I have already submitted similar pull requests to
execjs
,sprockets
, anduglifier
, somulti_json
need not be a dependency of Rails 4 applications. This should have the effect of making JSON parsing and generation somewhat faster by removing an abstraction layer that is no longer necessary.