-
Notifications
You must be signed in to change notification settings - Fork 24
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
How to make Oj optional #117
Comments
I use Oj instead of standard JSON for two reasons. First, it's faster. I actually fell into this trap when logging info entered by users in mobile apps. Thanks. |
Thank you so much for your quick response! I fully understand the benefits of Oj, but I think making the Ougai serializer pluggable will be very useful for this gem's fan. I'd appreciate it so much if you could proceed with this issue. |
I understood it. I think that your purpose can be achieved by the following code. require 'rubygems'
require 'ougai'
require 'json'
class StandardJSONSerializer < Ougai::Serializer
def serialize(data)
JSON.generate(data)
end
end
module Ougai
class Serializer
def self.for_json
StandardJSONSerializer.new
end
end
end
logger = Ougai::Logger.new(STDOUT)
logger.info('log') |
I'd suggest using multi_json, like many other gems. |
I decided that Ougai should not use multi_json from now based on the following links.
I want to keep Oj and JrJackson as default, but allow users to change their custom serializer. |
Sounds good. How will not Ougai install Oj if a user wants to install another JSON library? |
Ougai have already been used by a considerable number of applications, so I'm carefully considering how to make the users install OJ(JrJackson) separately. |
Hello. I have some reason not to be able to use
Oj
, so is there a way to use another JSON library like the standard libraryJSON
instead ofOj
?When I look into the code, it seems hard to replace
Ougai::Serializer.for_json
with some serializer without any monkey-patch.ougai/lib/ougai/formatters/for_json.rb
Line 15 in 7347135
If we could make
Oj
an optional dependency, it would be ideal for me.ougai/ougai.gemspec
Line 30 in 7347135
I would appreciate it if you would consider it. Thanks.
The text was updated successfully, but these errors were encountered: