Skip to content
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

.optimize_rails() ? #16

Open
feliperaul opened this issue Aug 6, 2020 · 3 comments
Open

.optimize_rails() ? #16

feliperaul opened this issue Aug 6, 2020 · 3 comments

Comments

@feliperaul
Copy link

Oj has a very nice Oj.optimize_rails() method that automagically makes Rails use Oj for all it's JSON needs (source: https://github.com/ohler55/oj/blob/develop/pages/Rails.md)

Is there a plan for something as easy to install in Rails for this gem?

@anilmaurya
Copy link
Owner

There is no such plan but surely it will be a good addition.

Are you interested in adding it ?

@totrash
Copy link

totrash commented Dec 26, 2020

oj is a parser and marshaller. (Oj.load, Oj.dump)
fast_jsonparser is a parser only.

@nathancolgate
Copy link

FWIW: I threw this monkey patch in an initializer:

module ActiveRecord
  module Type
    class Json < ActiveModel::Type::Value
      def deserialize(value)
        return value unless value.is_a?(::String)
        FastJsonparser.parse(value)
      end
    end
  end
end

We're decoding huge arrays out of Postgres and saw a 5x improvement. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants