I am trying to get user data in my Rails app.
I am doing this:
url_so = "http://api.stackoverflow.com/1.0/users/231917?type=jsontext"
curl = Curl::Easy.new(url_so)
curl.perform
data_obj = JSON.parse(curl.body_str)
But, the JSON parser says its not a correct format. So, when I did a curl.body_str
, I got this.
=> "\037\213\b\000\000\000\000\000\004\000\354\275\a`\034I\226%&/m\312{\177J\365J\327\340t\241\b\200`\023$\330\220@\020\354\301\210\315\346\222\354\035iG#)\253*\201\312eVe]f\026@\314\355\235\274\367\336{\357\275\367\336{\357\275\367\272;\235N'\367\337\377?\\fd\001l\366\316J\332\311\236!\200\252\310\037?~|\037?\"~\361o\234\244\351Gm\325f\345G\217\322\335\021\377\271\312.\362\360\257\246\370\001>\271\267#\037\255\233\274n\350\357\357\341\2574\375\305\362C\277\370\375\213\031}\265wo\367\341\356\203Q\370M{\275\002\230\217\352\374\242h\332\274\316g\037\271\026\323:\317\332\242Z\376.......
Any suggestions? How can I fetch a JSON file?
I am new to Ruby on Rails too, so is there any better gem to access the SO API?
SOLUTION:
This works, the problem was it was GZIP
curl = Curl::Easy.new(url_so)
curl.perform
json_data = ActiveSupport::Gzip.decompress(curl.body_str)