serde-query
Welcome to serde-query, a Rust library that lets you write jq-like queries for your data.
Why serde-query?
- Efficiency: With serde-query, you can efficiently extract exactly what you need without wasting the memory.
- Helpful error messages: When queries fail, you'll get clear, concise error messages that tell you where and why the failure happens.
- Flexibility: serde-query supports any serde-compatible data formats.
Getting started
To get started with serde-query, add it to your Rust project using Cargo:
Or, add it to your Cargo.toml
:
[]
= "0.2.0"
Example
Array queries
use ;
let document = json!.to_string;
// You can use `Query<T>` as a `Deserialize` type for any `Deserializer`
// and convert the result to the desired type using `From`/`Into`.
let data: Data = ?.into;
assert_eq!;
assert_eq!;
Errors
use Deserialize;
let error = .unwrap_err;
assert_eq!;
Note
This library generates Rust types for each query segment (e.g., .commit
, .commit.message
, etc.), which may lead to binary bloat and longer compile time.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.