Sha256: 93dc52dac29cce2c27b4ab7e24530fcbe33824f21326b75ad42bedbc41d75004
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require 'json' require 'pathname' module JMESPath autoload :CachingParser, 'jmespath/caching_parser' autoload :Errors, 'jmespath/errors' autoload :ExprNode, 'jmespath/expr_node' autoload :Lexer, 'jmespath/lexer' autoload :Nodes, 'jmespath/nodes' autoload :OptimizingParser, 'jmespath/optimizing_parser' autoload :Parser, 'jmespath/parser' autoload :Runtime, 'jmespath/runtime' autoload :Token, 'jmespath/token' autoload :TokenStream, 'jmespath/token_stream' autoload :VERSION, 'jmespath/version' class << self # @param [String] expression A valid # [JMESPath](https://github.com/boto/jmespath) expression. # @param [Hash] data # @return [Mixed,nil] Returns the matched values. Returns `nil` if the # expression does not resolve inside `data`. def search(expression, data, runtime_options = {}) data = case data when Hash, Struct then data # check for most common case first when Pathname then load_json(data) when IO, StringIO then JSON.load(data.read) else data end Runtime.new(runtime_options).search(expression, data) end # @api private def load_json(path) JSON.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read }) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
burtpath-1.1.2 | lib/jmespath.rb |
burtpath-1.1.1 | lib/jmespath.rb |