Skip to content

Instantly share code, notes, and snippets.

@gkop
Last active August 29, 2015 13:57
Show Gist options
  • Save gkop/9628598 to your computer and use it in GitHub Desktop.
Save gkop/9628598 to your computer and use it in GitHub Desktop.
Debug json API response with object in pry
#!/usr/bin/env ruby
# Usage:
# $ curl http://date.jsontest.com | ./debug_json.rb
r = $stdin.dup
input = r.read
$stdin.reopen("/dev/tty")
require 'json'
require 'recursive-open-struct'
require 'awesome_print'
hash = JSON.parse(input)
obj = RecursiveOpenStruct.new(JSON.parse(input))
require 'pry'
require 'pry-plus'
ap hash # would be cool if this paged
binding.pry
@linkwoman
Copy link

I had to rvm gemset use global and gem install all those required gems. Now it works like a charm.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment