echo '{"a":1,"b":2}' | ./jr 'puts json.select{|k,v|v == 2}.keys.last'
Last active
October 18, 2016 04:30
-
-
Save serihiro/bcb6d893560f076cb787dfd1fcf5220a to your computer and use it in GitHub Desktop.
jqっぽくrubyで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
#!/bin/sh | |
stdin=`cat -` | |
ruby ./jr.rb $stdin $@ |
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
require 'json' | |
json = JSON.parse(ARGV[0]) | |
unless ARGV[1].nil? | |
eval(ARGV[1..-1].join(' ')) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment