Module rsonpath_lib::query
source · Expand description
Defines JSONPath query structure and parsing logic.
Examples
To create a query from a query string:
let query_string = "$..person..phoneNumber";
let query = JsonPathQuery::parse(query_string)?;
// Query structure is a linear sequence of nodes:
// Root '$', descendant '..person', descendant '..phoneNumber'.
let root_node = query.root();
let descendant_node1 = root_node.child().unwrap();
let descendant_node2 = descendant_node1.child().unwrap();
assert!(root_node.is_root());
assert!(descendant_node1.is_descendant());
assert!(descendant_node2.is_descendant());
// Final node will have a None child.
assert!(descendant_node2.child().is_none());
assert_eq!(descendant_node1.label().unwrap(), "person".as_bytes());
assert_eq!(descendant_node2.label().unwrap(), "phoneNumber".as_bytes());
Modules
- Automaton representations of a JSONPath query.
- Utility for building a
JsonPathQuery
programatically. - 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.
- Label 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.
Type Definitions
- Label byte alignment for SIMD.