Skip to content

Instantly share code, notes, and snippets.

@matiskay
Created January 4, 2012 03:31
Show Gist options
  • Save matiskay/1558351 to your computer and use it in GitHub Desktop.
Save matiskay/1558351 to your computer and use it in GitHub Desktop.
Pretty json Using Ruby

Pretty json Using Ruby

This is a simple snippet to show how to work with json and ruby. This code is really messy. Sorry

TODO

  • Refactor this code.
  • Refactoring is welcome.
require 'json'
require 'net/http'
require 'uri'
url = 'awesome_url.json'
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
json_file = http.get(url)
#puts json_file.body
puts jj JSON.parse(json_file.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment