Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#41] Add a better example to the Filter section in main docs #54

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions serde_json_path/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased

- **documentation**: Add line describing Descendant Operator ([#53])
- **documentation**: Improve example in Filter section of main docs ([#54])

[#53]: https://github.com/hiltontj/serde_json_path/pull/53
[#54]: https://github.com/hiltontj/serde_json_path/pull/54

# 0.6.2 (13 July 2023)

Expand Down
18 changes: 11 additions & 7 deletions serde_json_path/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,18 @@
//! # use serde_json::json;
//! # use serde_json_path::JsonPath;
//! # fn main() -> Result<(), serde_json_path::ParseError> {
//! let value = json!([
//! { "title": "Great Expectations", "price": 10 },
//! { "title": "Tale of Two Cities", "price": 8 },
//! { "title": "David Copperfield", "price": 17 }
//! ]);
//! let path = JsonPath::parse("$[?@.price > $[0].price].title")?;
//! let value = json!({
//! "threshold": 40,
//! "readings": [
//! { "val": 35, "msg": "foo" },
//! { "val": 40, "msg": "bar" },
//! { "val": 42, "msg": "biz" },
//! { "val": 48, "msg": "bop" },
//! ]
//! });
//! let path = JsonPath::parse("$.readings[? @.val > $.threshold ].msg")?;
//! let nodes = path.query(&value).all();
//! assert_eq!(nodes, vec!["David Copperfield"]);
//! assert_eq!(nodes, vec!["biz", "bop"]);
//! # Ok(())
//! # }
//! ```
Expand Down