macro_rules! json_path { ( $( $piece:expr ),+ ) => { ... }; }
Expand description
Creates a JSONPath from path pieces
The arguments to this macro represent the path pieces:
- numbers of type
u32are converted toJsonPathPiece::ArrayItem - strings are converted to
JsonPathPiece::ObjectMember
At least one path piece argument must be provided.
Examples
let json_path = json_path!["outer", 3, "inner"];
assert_eq!(
json_path,
[
JsonPathPiece::ObjectMember("outer".to_owned()),
JsonPathPiece::ArrayItem(3),
JsonPathPiece::ObjectMember("inner".to_owned()),
]
);