Expand description
Defines JSONPath query structure and parsing logic.
Examples
To create a query from a query string:
let query_string = "$..phoneNumbers[*].number";
let query = JsonPathQuery::parse(query_string)?;
// Query structure is a linear sequence of nodes:
// Root '$', descendant '..phoneNumbers', child wildcard, child 'number'.
let root_node = query.root();
let descendant_node = root_node.child().unwrap();
let child_wildcard_node = descendant_node.child().unwrap();
let child_node = child_wildcard_node.child().unwrap();
assert!(root_node.is_root());
assert!(descendant_node.is_descendant());
assert!(child_wildcard_node.is_any_child());
assert!(child_node.is_child());
// Final node will have a None child.
assert!(child_node.child().is_none());
assert_eq!(descendant_node.member_name().unwrap(), "phoneNumbers".as_bytes());
assert_eq!(child_wildcard_node.member_name(), None);
assert_eq!(child_node.member_name().unwrap(), "number".as_bytes());
Modules
- Automaton representations of a JSONPath query.
- Utility for building a
JsonPathQuery
programmatically. - Error types for the
query
module.
Structs
- JSONPath query structure represented by the root link of the
JsonPathQueryNode
list. - Iterator over query nodes traversing the parent-child relation.
- String to search for in a JSON document, conforming to the RFC7159, section 7
- Array index to search for in a JSON document.
Enums
- Linked list structure of a JSONPath query.
Traits
- Equips a struct with information on the type of
JsonPathQueryNode
it represents and methods to extract query elements from it.