Module: JMESPath

Defined in:
lib/jmespath.rb,
lib/jmespath/lexer.rb,
lib/jmespath/token.rb,
lib/jmespath/errors.rb,
lib/jmespath/parser.rb,
lib/jmespath/runtime.rb,
lib/jmespath/version.rb,
lib/jmespath/expr_node.rb,
lib/jmespath/token_stream.rb,
lib/jmespath/caching_parser.rb,
lib/jmespath/tree_interpreter.rb

Defined Under Namespace

Modules: Errors Classes: CachingParser, ExprNode, Lexer, Parser, Runtime, Token, TokenStream, TreeInterpreter

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.load_json(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/jmespath.rb', line 36

def load_json(path)
  MultiJson.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
end

.search(expression, data) ⇒ Mixed?



25
26
27
28
29
30
31
32
33
# File 'lib/jmespath.rb', line 25

def search(expression, data)
  data = case data
    when Hash, Struct then data # check for most common case first
    when Pathname then load_json(data)
    when IO, StringIO then MultiJson.load(data.read)
    else data
    end
  Runtime.new.search(expression, data)
end