Skip to content

Instantly share code, notes, and snippets.

@serihiro
Last active October 18, 2016 04:30
Show Gist options
  • Save serihiro/bcb6d893560f076cb787dfd1fcf5220a to your computer and use it in GitHub Desktop.
Save serihiro/bcb6d893560f076cb787dfd1fcf5220a to your computer and use it in GitHub Desktop.
jqっぽくrubyでjsonをシュッとしたいときに使うなにか。
echo '{"a":1,"b":2}' | ./jr 'puts json.select{|k,v|v == 2}.keys.last'
#!/bin/sh
stdin=`cat -`
ruby ./jr.rb $stdin $@
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