Open dblock opened 6 years ago
Both Ruby and Rails allow for swapping the default JSON parser:
require 'json'
JSON.parser
# => JSON::Ext::Parser
JSON.parse '{"foo":1}'
# => {"foo"=>1}
JSON.parser = nil
JSON.parse '{"foo":1}'
# => NoMethodError: undefined method `new' for nil:NilClass
require 'oj'
JSON.parser = Oj
JSON.parse '{"foo":1}'
# => {"foo"=>1}
Oj even has its own mechanism to inject itself to Rails:
require 'active_support/json/encoding'
ActiveSupport::JSON::Encoding.json_encoder
# => ActiveSupport::JSON::Encoding::JSONGemEncoder
require 'oj'
Oj.optimize_rails
ActiveSupport::JSON::Encoding.json_encoder
# => Oj::Rails::Encoder
So I'm not sure if it makes sense for this gem to depend on third-party libraries.
Want to be able to use multi_json or OJ.