Serde Query: An efficient query language for Serde

serde-query provides a query language for Serde data model.

serde-query is:

Example

```rust use serde_query::{DeserializeQuery, Query};

[derive(DeserializeQuery)]

struct Data { #[query(".commit.authors.[0]")] firstauthor: String, #[query(".hash")] hashvalue: u64, }

let document = serdejson::tostring(&serde_json::json!({ "commit": { "authors": ["Kou", "Kasumi", "Masaru"], "date": "2020-09-10", }, "hash": 0xabcd, }))?;

// 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 = serdejson::fromstr::>(&document)?.into();

asserteq!(data.firstauthor, "Kou"); asserteq!(data.hashvalue, 0xabcd); ```

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

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.