-
Notifications
You must be signed in to change notification settings - Fork 966
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
httparty fails to parse certain json data #75
Comments
Hi. Does anyone have a way to handle this? I have the same problem. |
For a reason I do not know, httparty uses Crack::JSON, but JSON with JSON.parse works fine. I going to monkey patch this on my version. I anyone has a clue please comment :)
def json
Crack::JSON.parse(body)
end
|
I'm also having a problem with Crack (huhu) and Ruby 1.9.2…
Seems not be the same as yours however. |
Indeed. |
I'm also having this problem. Confim using JSON lib solves. |
The same here on larger data sets: /home/cs/.rvm/gems/ruby-1.9.2-head/gems/crack-0.1.8/lib/crack/json.rb:54: stack level too deep (SystemStackError) |
Note: the same JSON data it is received without problems by rest-client or curl |
I was having some JSON issues with Crack too (different ones). I do wish Crack wasn't the default, it seems really out of date now. But note you don't actually have to monkeypatch to get around it, HTTParty lets you specify the parser like
|
See this pull request as well: #89 Until that's incorporated, monkey patching with the following works well for me: module HTTParty
class Parser
def json
MultiJson.decode(body)
end
end
end And in your Gemfile: gem 'multi_json' |
This should be fixed as multi json is the default. Just use it with a good json gem and you are fine. |
url="http://gdata.youtube.com/feeds/api/users/dutchlove1976?alt=json"
JSON.parse(open(url){|r| p r.read }) #no problem
r = HTTParty.send(:get,url ) =>
Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/crack-0.1.8/lib/crack/json.rb:19:in
gsub' from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/crack-0.1.8/lib/crack/json.rb:19:in
unescape'from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/crack-0.1.8/lib/crack/json.rb:12:in
parse' from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/parser.rb:116:in
json'from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/parser.rb:136:in
parse_supported_format' from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/parser.rb:103:in
parse'from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/parser.rb:66:in
call' from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/request.rb:217:in
parse_response'from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/request.rb:189:in
handle_response' from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty/request.rb:71:in
perform'from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty.rb:394:in
perform_request' from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty.rb:346:in
get'from /Users/jtoy/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty.rb:426:in `get'
The text was updated successfully, but these errors were encountered: