Closed manuelvanrijn closed 6 months ago
Similar problem here. Where default JSON gem returns OpenStructs (although thats deprecated as well, but it still does it) yal doesn't
Just upgrading mailjet broke my application. Had to limit to version '< 1.7.8' to make it work.
Fixed in 1.7.9 Faraday HTTP client upgrade scheduled for next month
Introduction
After the introduction of #243, I'm getting the error
JSON::ParserError: input must be a string or IO
on places where I'm doing aJSON.parse(response.body)
using the http gem. Althoughyajl-ruby
claims in the README that it should be a drop-in replacement, it seems it doesn't work for this use case. Also, the author says he wants to drop the JSON gem compat API in yajl-ruby 2.0Problem
The main problem is that this gem is uses
require 'yajl/json_gem'
which replaces theKernel::JSON
for the yajl one.Reproduce
Workaround
To work around this problem, you could
.to_s
the response so thatYajl
can parse the bodyPossible solution
Replace
require 'yajl/json_gem'
forrequire 'yajl'
and implement theYajl::Encoder.encode
where.to_json
is being used andYajl::Parser.parse
instead of theJSON.parse
. That way we're not replacing theJSON
object and give the rest of the applications the ability to opt in (or not) for usingYajl