Currently, when running in mimic_json or rails mode, Oj appears to do a hard-check on the argument passed to JSON.parse, and raises an ArgumentError if it is not a String or IO object.
This is a deviation from the standard lib JSON.parse, which allows for any string-like or IO-like object. Many gems and libraries have used (abused?) this feature.
Test case:
require 'oj'
Oj.mimic_JSON
Oj.add_to_json
class StringPlus
def initialize(str)
@str = str
end
def to_str
@str
end
alias to_s to_str
end
test_str = StringPlus.new('{"testing": 123}')
JSON.parse(test_str)
Ouch, ok, I'll test the json gem and update Oj in mimic mode to handle that with a call to to_s and check for what ever IO methods are needed before that.
Great! Thanks for the fast response!
Might take a day or two.
or maybe less. :-) please try the latest master.
3.0.9 released
Checking it now, preliminary test seem to indicate success
Can this be closed?
Yep, sorry, it works perfectly!
Most helpful comment
Might take a day or two.