Sha256: 60acb64e200ec77531b59d1b96ace2cb18bea75ca90fd14c15c952a984c35d02
Contents?: true
Size: 552 Bytes
Versions: 8
Compression:
Stored size: 552 Bytes
Contents
#!/usr/local/env ruby require 'jsonpath' require 'json' def usage puts "jsonpath [expression] (file|string) If you omit the second argument, it will read stdin, assuming one valid JSON object per line. Expression must be a valid jsonpath expression." exit! end usage unless ARGV[0] jsonpath = JsonPath.new(ARGV[0]) case ARGV[1] when nil #stdin until STDIN.eof? puts jsonpath.on(JSON.parse(STDIN.readline)).to_a.to_json end when String puts jsonpath.on(JSON.parse(File.exist?(ARGV[1]) ? File.read(ARGV[1]) : ARGV[1])).to_a.to_json end
Version data entries
8 entries across 8 versions & 1 rubygems