MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / coerced_eq

Function coerced_eq

nodedb-query/src/json_ops.rs:57–65  ·  view source on GitHub ↗

Check equality with type coercion. Handles `"5" == 5` by coercing both sides to f64 when one is a number and the other is a numeric string.

(a: &serde_json::Value, b: &serde_json::Value)

Source from the content-addressed store, hash-verified

55/// Handles `"5" == 5` by coercing both sides to f64 when one is a
56/// number and the other is a numeric string.
57pub fn coerced_eq(a: &serde_json::Value, b: &serde_json::Value) -> bool {
58 if a == b {
59 return true;
60 }
61 if let (Some(af), Some(bf)) = (json_to_f64(a, true), json_to_f64(b, true)) {
62 return (af - bf).abs() < f64::EPSILON;
63 }
64 false
65}
66
67/// Check if a JSON value is truthy (for boolean contexts).
68///

Callers 3

matches_metadata_filterFunction · 0.70
eval_scopeMethod · 0.50
eval_binary_opFunction · 0.50

Calls 1

json_to_f64Function · 0.70

Tested by

no test coverage detected