Rust implementation of JMESPath, a query language for JSON
Rust
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
benches Adding Runtime. Other API tweaks Dec 15, 2016
jmespath-cli Prep 0.2.0 release Aug 26, 2017
jmespath-macros Prep 0.2.0 release Aug 26, 2017
src upgrade to serde 1.0 Aug 23, 2017
tests
.gitignore Renaming to jmespath-macros May 2, 2016
.travis.yml Using docs.rs and updating some docs Jan 8, 2017
CHANGELOG.md
Cargo.toml Prep 0.2.0 release Aug 26, 2017
LICENSE Adding a license and lexer docs Jun 6, 2015
README.md Prep 0.2.0 release Aug 26, 2017
build.rs upgrade to serde 1.0 Aug 23, 2017

README.md

JMESPath for Rust

Build Status Coverage Status Current Version ![Gitter](https://badges.gitter.im/Join Chat.svg)

Rust implementation of JMESPath, a query language for JSON.

Documentation

Installing

This crate is on crates.io and can be used by adding jmespath to the dependencies in your project's Cargo.toml.

[dependencies]
jmespath = "^0.2.0"

If you are using a nightly compiler, or reading this when specialization in Rust is stable (see rust#31844), then enable the specialized feature to switch on usage of specialization to get more efficient code:

[dependencies.jmespath]
version = "^0.2.0"
features = ["specialized"]

Examples

extern crate jmespath;

let expr = jmespath::compile("foo.bar").unwrap();

// Parse some JSON data into a JMESPath variable
let json_str = r#"{"foo": {"bar": true}}"#;
let data = jmespath::Variable::from_json(json_str).unwrap();

// Search the data with the compiled expression
let result = expr.search(data).unwrap();
assert_eq!(true, result.as_boolean().unwrap());

jmespath! compiler plugin

The jmespath-macros crate provides the jmespath! macro used to statically compile JMESPath expressions.

By statically compiling JMESPath expressions, you pay the cost of parsing and compiling JMESPath expressions at compile time rather than at runtime, and you can be sure that the expression is valid if your program compiles.

Note: This only works with a nightly compiler.

#![feature(plugin)]

#![plugin(jmespath_macros)]
extern crate jmespath;

fn main() {
    // Create our statically compiled expression. The build will fail
    // if the expression is invalid.
    let expr = jmespath!("foo.bar");

    // Parse some JSON data into a JMESPath variable
    let json_str = r#"{"foo": {"bar": true}}"#;
    let data = jmespath::Variable::from_json(json_str).unwrap();
    let result = expr.search(data).unwrap();
    assert_eq!(true, result.as_boolean().unwrap());
}