pub struct JqExpression(/* private fields */);Expand description
A compiled jq expression for querying JSON bodies.
Wraps a jaq filter that can be compiled once and reused for multiple requests. This avoids the overhead of parsing and compiling the jq expression on each request.
§Examples
use hitbox_http::predicates::body::JqExpression;
// Compile a jq expression
let expr = JqExpression::compile(".user.id").unwrap();
// Apply to JSON data
let json = serde_json::json!({"user": {"id": 42}});
let result = expr.apply(json);
assert_eq!(result, Some(serde_json::json!(42)));§Errors
compile returns Err if the jq expression is invalid.
Implementations§
Trait Implementations§
Source§impl Clone for JqExpression
impl Clone for JqExpression
Source§fn clone(&self) -> JqExpression
fn clone(&self) -> JqExpression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for JqExpression
impl RefUnwindSafe for JqExpression
impl Send for JqExpression
impl Sync for JqExpression
impl Unpin for JqExpression
impl UnwindSafe for JqExpression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more