Skip to content
Javascript implementation of JMESPath, a query language for JSON
JavaScript
Find file
Latest commit 43163b4 @jamesls jamesls Merge branch 'perf-improve'
* perf-improve:
  Update perf script
  Replace dynamic dispatch with switch statement
  Don't export parser
  Use type vars instead of strings for type decls
  Clean up linting errors
  Combine led methods to a single method
  Collapse nud methods into a single mthod
  Upgrade deps
Failed to load latest commit information.
artifacts
test Sync latest compliance tests from jmespath.test
.eslintrc Full support of JMESPath except for functions
.gitignore Initial commit of jmespath.js
.travis.yml Add iojs testing to travis ci
Gruntfile.js Full support of JMESPath except for functions
LICENSE Add apache 2 license
README.md Fix travis ci badge link
bower.json
jmespath.js Replace dynamic dispatch with switch statement
jp.js Modify jp command to read input from stdin
package.json Upgrade deps
perf.js Update perf script

README.md

jmespath.js

Build Status

jmespath.js is a javascript implementation of JMESPath, which is a query language for JSON. It will take a JSON document and transform it into another JSON document through a JMESPath expression.

Using jmespath.js is really easy. There's a single function you use, jmespath.search:

> var jmespath = require('jmespath');
> jmespath.search({foo: {bar: {baz: [0, 1, 2, 3, 4]}}}, "foo.bar.baz[2]")
2

In the example we gave the search function input data of {foo: {bar: {baz: [0, 1, 2, 3, 4]}}} as well as the JMESPath expression foo.bar.baz[2], and the search function evaluated the expression against the input data to produce the result 2.

The JMESPath language can do a lot more than select an element from a list. Here are a few more examples:

> jmespath.search({foo: {bar: {baz: [0, 1, 2, 3, 4]}}}, "foo.bar")
{ baz: [ 0, 1, 2, 3, 4 ] }

> jmespath.search({"foo": [{"first": "a", "last": "b"},
                           {"first": "c", "last": "d"}]},
                  "foo[*].first")
[ 'a', 'c' ]

> jmespath.search({"foo": [{"age": 20}, {"age": 25},
                           {"age": 30}, {"age": 35},
                           {"age": 40}]},
                  "foo[?age > `30`]")
[ { age: 35 }, { age: 40 } ]

More Resources

The example above only show a small amount of what a JMESPath expression can do. If you want to take a tour of the language, the best place to go is the JMESPath Tutorial.

One of the best things about JMESPath is that it is implemented in many different programming languages including python, ruby, php, lua, etc. To see a complete list of libraries, check out the JMESPath libraries page.

And finally, the full JMESPath specification can be found on the JMESPath site.

Something went wrong with that request. Please try again.