anilmaurya / fast_jsonparser

Fastest Json parser for Ruby, wrapper for simdjson
MIT License
307 stars 10 forks source link

.optimize_rails() ? #16

Open feliperaul opened 4 years ago

feliperaul commented 4 years ago

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 commented 4 years ago

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

Are you interested in adding it ?

totrash commented 3 years ago

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

nathancolgate commented 2 years ago

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!