I'm still new to Ruby and trying to use the HTTParty gem to help me write an API Wrapper. I feed HTTParty::get a URI and it parses JSON data. From a quick glance and the way the returned result behaves, it looks like a Hash, but is it? I can't seem to find information online. Another post on StackOverflow shows to use HTTParty::get(...).parsed_response to get the Hash, but this seems outdated.

有帮助吗?

解决方案

Do this in the console:

>require 'httparty'
 => true
> response = HTTParty.get( "..." )
 ....
> response.class
 => HTTParty::Response

So the response from HTTParty.get is an HTTParty::Response object.

See this blogpost titled "It's Time To HTTParty!" to learn more about how to work this response.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top