You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oj ignores to_json methods defined on a class and encodes as it normally would without any to_json method being defined.
require 'json'
require 'oj'
class Klass
def self.to_json(*)
'correct_result'
end
end
puts JSON.dump(Klass)
puts Klass.to_json
puts Oj.dump(Klass)
puts Oj::Rails.encode(Klass)
This will output:
correct_result
correct_result
{"^c":"Klass"}
"Klass"
The text was updated successfully, but these errors were encountered:
Thank you so much! This isn't urgent as I was able to implement a workaround using the Singleton module, but I thought I'd bring it to your attention just so you're aware.
Oj
ignoresto_json
methods defined on a class and encodes as it normally would without anyto_json
method being defined.This will output:
correct_result
correct_result
{"^c":"Klass"}
"Klass"
The text was updated successfully, but these errors were encountered: