ohler55 / oj

Optimized JSON
http://www.ohler.com/oj
MIT License
3.12k stars 250 forks source link

ArgumentError: options must be a hash. #238

Closed maksymst closed 9 years ago

maksymst commented 9 years ago

Hello Oj.mimic_JSON produces arguments error. See below

2.2.0 :003 > JSON '{"test": 1}'
 => {"test"=>1} 
2.2.0 :004 > Oj.mimic_JSON
 => JSON 
2.2.0 :005 > JSON '{"test": 1}'
ArgumentError: options must be a hash.
        from /home/maxim/.rvm/gems/ruby-2.2.0@mytv/gems/json-1.8.2/lib/json/common.rb:468:in `parse'
        from /home/maxim/.rvm/gems/ruby-2.2.0@mytv/gems/json-1.8.2/lib/json/common.rb:468:in `JSON'
        from (irb):5
        from /home/maxim/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'

Ruby 2.2.0, Oj 2.12.7

Thank you

ohler55 commented 9 years ago

I would have expected an undefined method error. JSON is the module name. I see that the JSON lib does treat it as a method as well though. Let me look into it.

ohler55 commented 9 years ago

Just checked in version 2.12.8 that adds the JSON method when mimic_JSON is called.

maksymst commented 9 years ago

Hello @ohler55 I updated oj to new version but I still have same error

ohler55 commented 9 years ago

I see, if the son gem is not loaded Oj works fine. With the json gem loaded first there is a problem. I'll see what I can do.

ohler55 commented 9 years ago

Ok, another attempt in github. Please give it a try.

ohler55 commented 9 years ago

Have you retested on the latest?

ohler55 commented 9 years ago

Release 2.12.9 made. Tests passed for me. No response on this issue. Closing.