Last active
August 29, 2015 13:57
-
-
Save gkop/9628598 to your computer and use it in GitHub Desktop.
Debug json API response with object in pry
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
#!/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, replace the > debug_JSON.rb
with | ./debug_JSON.rb
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
Thanks Gabe. How do I run it? I thought like this:
curl -XPOST 'http://54.81.34.92:8080/UserQueryServer-0.1/rest/elements/query' -d 'nouns=metabolites&verbs=&adjectives=&verbPercentage=.33&nounPercentage=.33&adjectivePercentage=.33&sourceTypes=drug&size=1' > debug_JSON.rb
I get back nothing. The curl works otherwise.