jmespath
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Jmespath is a powerful JavaScript library designed to work as a query language for JSON. Its main purpose is to allow the transformation of JSON documents into other JSON documents using JMESPath expressions. It's a beneficial tool when dealing with complex JSON data structures. Supporting a wide variety of operations, from simple value retrieval to more complex computations, it's an excellent tool for efficiently working with JSON data.
The use of jmespath in your JavaScript project is pretty straightforward. First, ensure you have it installed in your project via npm. To use it, you would require the library and then call jmespath.search
function. Here are some code examples showcasing its usage:
var jmespath = require('jmespath');
//simple value retrieval
jmespath.search({foo: {bar: {baz: [0, 1, 2, 3, 4]}}}, "foo.bar.baz[2]") //returns: 2
//fetching a nested object
jmespath.search({foo: {bar: {baz: [0, 1, 2, 3, 4]}}}, "foo.bar") //returns: { baz: [ 0, 1, 2, 3, 4 ] }
//retrieving values from arrays
jmespath.search({"foo": [{"first": "a", "last": "b"},{"first": "c", "last": "d"}]},"foo[*].first") //returns: [ 'a', 'c' ]
//conditions
jmespath.search({"foo": [{"age": 20}, {"age": 25},{"age": 30}, {"age": 35},{"age": 40}]},"foo[?age > `30`]") //returns: [ { age: 35 }, { age: 40 } ]
For in-depth information about how to build queries and other functionalities provided by jmespath, you can read the detailed JMESPath Tutorial which provides a comprehensive walk-through of the language's capabilities. A complete list of libraries for various programming languages can be found on the official JMESPath libraries page. For the full specification of the JMESPath language, please refer to the official JMESPath site. These resources are excellent starting points to fully leverage the potential of the JMESPath query language in your JavaScript applications.