Module: JMESPath
- Defined in:
- lib/jmespath.rb,
lib/jmespath/util.rb,
lib/jmespath/lexer.rb,
lib/jmespath/nodes.rb,
lib/jmespath/token.rb,
lib/jmespath/errors.rb,
lib/jmespath/parser.rb,
lib/jmespath/runtime.rb,
lib/jmespath/version.rb,
lib/jmespath/nodes/or.rb,
lib/jmespath/nodes/and.rb,
lib/jmespath/nodes/not.rb,
lib/jmespath/nodes/pipe.rb,
lib/jmespath/nodes/field.rb,
lib/jmespath/nodes/index.rb,
lib/jmespath/nodes/slice.rb,
lib/jmespath/token_stream.rb,
lib/jmespath/nodes/current.rb,
lib/jmespath/nodes/flatten.rb,
lib/jmespath/nodes/literal.rb,
lib/jmespath/caching_parser.rb,
lib/jmespath/nodes/function.rb,
lib/jmespath/nodes/condition.rb,
lib/jmespath/nodes/comparator.rb,
lib/jmespath/nodes/expression.rb,
lib/jmespath/nodes/projection.rb,
lib/jmespath/nodes/subexpression.rb,
lib/jmespath/nodes/multi_select_hash.rb,
lib/jmespath/nodes/multi_select_list.rb
Defined Under Namespace
Modules: Errors, Nodes, Util Classes: CachingParser, Lexer, Parser, Runtime, Token, TokenStream
Constant Summary collapse
- VERSION =
File.read(File.('../../../VERSION', __FILE__)).strip
Class Method Summary collapse
- .load_json(path) ⇒ Object private
-
.search(expression, data, runtime_options = {}) ⇒ Mixed?
Returns the matched values.
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.
35 36 37 |
# File 'lib/jmespath.rb', line 35 def load_json(path) JSON.parse(File.open(path, 'r', encoding: 'UTF-8', &:read)) end |
.search(expression, data, runtime_options = {}) ⇒ Mixed?
Returns the matched values. Returns ‘nil` if the expression does not resolve inside `data`.
24 25 26 27 28 29 30 31 32 |
# File 'lib/jmespath.rb', line 24 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 JSON.parse(data.read) else data end Runtime.new().search(expression, data) end |