Skip to content

Commit

Permalink
docs: update JsonPath::query_located docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltontj committed Jan 29, 2024
1 parent 53135af commit 13a80ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions serde_json_path/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ impl JsonPath {
/// # use serde_json::{json, Value};
/// # use serde_json_path::{JsonPath,NormalizedPath};
/// # fn main() -> Result<(), serde_json_path::ParseError> {
/// let value = json!({"foo": [1, 2, 3, 4]});
/// let path = JsonPath::parse("$.foo[2:]")?;
/// let value = json!({"foo": {"bar": 1, "baz": 2}});
/// let path = JsonPath::parse("$.foo.*")?;
/// let query = path.query_located(&value);
/// let nodes: Vec<&Value> = query.nodes().collect();
/// assert_eq!(nodes, vec![3, 4]);
/// assert_eq!(nodes, vec![1, 2]);
/// let locs: Vec<String> = query
/// .locations()
/// .map(|loc| loc.to_string())
/// .collect();
/// assert_eq!(locs, ["$['foo'][2]", "$['foo'][3]"]);
/// assert_eq!(locs, ["$['foo']['bar']", "$['foo']['baz']"]);
/// # Ok(())
/// # }
/// ```
Expand Down

0 comments on commit 13a80ec

Please sign in to comment.