Skip to content

Instantly share code, notes, and snippets.

@hanssens
Created January 8, 2015 08:22
Show Gist options
  • Save hanssens/46f52ab4e7ae75962e0e to your computer and use it in GitHub Desktop.
Save hanssens/46f52ab4e7ae75962e0e to your computer and use it in GitHub Desktop.
Simple wrapper for http request and parsing JSON
##
# 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