-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
mimic_JSON compatibility with Faraday #411
Comments
Since the JSON gem also raises an exception it seems Oj is working as expected in mimicking the JSON gem. The same behavior is also present in a Rails console. The documentation for bot the JSON gem and Rails calls for the second argument, if present, to be an options hash. The faraday_middleware seems to have introduced a bug. Looking at the patch code it is clear they have introduced a bug as the @parse_options will end of defaulting to nil instead of |
@ohler55 it looks to me as it does not behave the same as the JSON gem, for example:
Then if I add Oj and attempt the same thing it blows up:
I have patched the faraday_middleware to fix the issue for now but just wanted to chime in on this here as it does look like Oj handles nil options differently. |
I stand corrected. For nil the behavior is different than an empty string, or any string for that matter.
I'll update Oj to special case nil. I thank you for making the change in faraday_middleware. |
I'm sorry for the confusion about the empty string. Thank you @stefansedich @ohler55 for making changes in your gems to fix the problem. |
Thank you for your understanding, I'll create a link to our PR to keep this tracked: |
Just released Oj 3.3.3 that allows a nil second argument to parse but continues to raise an exception on anything else other than a Hash. |
I just update gem version and all tests are passing. Thank you very much. |
Recent changes in FaradayMiddleware https://github.com/lostisland/faraday_middleware/pull/156/files
makes oj incompatible with it.
We use rails, faraday and oj.
Everything worked fine until change mentioned above.
Right now we receive ParsingError with a message: "options must be a hash".
This is the same message which you will receive calling JSON.parse with incorrect options.
Example:
I'm not sure if it is Oj error or faraday_middleware error.
For now, we need to remove oj completely or use faraday_middleware in the previous version.
The text was updated successfully, but these errors were encountered: