Skip to content
Ruby implementation of JMESPath
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark Running `rake benchmark` now performs the performance tests. Oct 27, 2014
tasks Update the bundled compliance tests fixing errors. Apr 4, 2018
.gitignore Removed simplecov usage. Jul 18, 2016
.yardopts Added `rake docs` using YARD. [ci skip] Oct 24, 2014 Added next release section to the changelog. Apr 4, 2018
LICENSE.txt Added the Apache 2 license to the repository and gem. Dec 4, 2014
Rakefile Running `rake benchmark` now performs the performance tests. Oct 27, 2014
jmespath.gemspec Fix typo of a license name in gemspec May 29, 2017


Gitter chat Build Status

An implementation of JMESPath for Ruby. This implementation supports searching JSON documents as well as native Ruby data structures.


$ gem install jmespath

Basic Usage

Call with a valid JMESPath search expression and data to search. It will return the extracted values.

require 'jmespath''', { foo: { bar: { baz: "value" }}})
#=> {baz: "value"}

In addition to accessing nested values, you can exact values from arrays.'[0]', { foo: { bar: ["one", "two"] }})
#=> "one"'[-1]', { foo: { bar: ["one", "two"] }})
#=> "two"'foo[*].name', {foo: [{name: "one"}, {name: "two"}]})
#=> ["one", "two"]

If you search for keys no present in the data, then nil is returned.'', { abc: "mno" })
#=> nil

See the JMESPath specification for a full list of supported search expressions.

Indifferent Access

The examples above show JMESPath expressions used to search over hashes with symbolized keys. You can use search also for hashes with string keys or Struct objects.'', { "foo" => { "bar" => "value" }})
#=> "value"

data ="value")
)'', data)
#=> "value"

JSON Documents

If you have JSON documents on disk, or IO objects that contain JSON documents, you can pass them as the data argument.,'/path/to/data.json'))'/path/to/data.json', 'r', encoding:'UTF-8') do |file|, file)

Links of Interest


This library is distributed under the apache license, version 2.0

Copyright 2014 Trevor Rowe; All rights reserved.

Licensed under the apache license, version 2.0 (the "license"); You may not use this library except in compliance with the license. You may obtain a copy of the license at:

Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied.

See the license for the specific language governing permissions and limitations under the license.

You can’t perform that action at this time.