Sha256: 415194826ba1f88c53d21a4d7e12487e5f1c2af354337dd91e8431e94302e070

Contents?: true

Size: 561 Bytes

Versions: 7

Compression:

Stored size: 561 Bytes

Contents

#!/usr/bin/env ruby

require 'jsonpathv2'
require 'multi_json'

def usage
  puts "jsonpathv2 [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 jsonpathv2 expression."
  exit!
end

usage unless ARGV[0]

jsonpathv2 = JsonPath.new(ARGV[0])
case ARGV[1]
when nil # stdin
  puts MultiJson.encode(jsonpathv2.on(MultiJson.decode(STDIN.read)))
when String
  puts MultiJson.encode(jsonpathv2.on(MultiJson.decode(File.exist?(ARGV[1]) ? File.read(ARGV[1]) : ARGV[1])))
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jsonpathv2-0.0.9 bin/jsonpathv2
jsonpathv2-0.0.8 bin/jsonpathv2
jsonpathv2-0.0.7 bin/jsonpathv2
jsonpathv2-0.0.6 bin/jsonpathv2
jsonpathv2-0.0.4 bin/jsonpathv2
jsonpathv2-0.0.3 bin/jsonpathv2
jsonpathv2-0.0.2 bin/jsonpathv2