pub enum JsonCmp {
Eq(Value),
Ne(Value),
Gt(Value),
Lt(Value),
Ge(Value),
Le(Value),
In(Vec<Value>),
IsNull,
NotNull,
}Expand description
Represents comparison operations for JSON values.
Used with JsonFilter::Extract to compare extracted values against targets.
Variants§
Eq(Value)
Equal comparison.
Ne(Value)
Not equal comparison.
Gt(Value)
Greater than comparison.
Lt(Value)
Less than comparison.
Ge(Value)
Greater than or equal comparison.
Le(Value)
Less than or equal comparison.
In(Vec<Value>)
Check if value is in the provided list.
IsNull
Check if value is null or path doesn’t exist.
NotNull
Check if value is not null.
Implementations§
Source§impl JsonCmp
impl JsonCmp
Sourcepub fn matches(&self, value: Option<Value>) -> bool
pub fn matches(&self, value: Option<Value>) -> bool
Matches the given JSON value against the comparison operation.
In case the provided value is None, and the comparison is IsNull, it returns true.
Otherwise, it returns false for None values.
§Arguments
value- An optional JSON value to compare.
§Returns
true if the value matches the comparison operation, false otherwise.
Numeric values (every integer variant and Value::Decimal) are compared by
magnitude, regardless of their variant, for every operator including Eq, Ne
and In. Other values are compared with the Value ordering.