Created
January 8, 2015 08:22
-
-
Save hanssens/46f52ab4e7ae75962e0e to your computer and use it in GitHub Desktop.
Simple wrapper for http request and parsing JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Simple JSON wrapper | |
require 'json' | |
require 'net/http' | |
class Executor | |
def initialize | |
end | |
def get(endpoint) | |
uri = URI.parse(endpoint) | |
response = Net::HTTP.get_response(uri) | |
return JSON.parse(response.body) | |
end | |
end | |
exec = Executor.new | |
json = exec.get("http://date.jsontest.com") | |
p json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment