Compare two JSON values with type coercion. Tries numeric comparison first (with bool coercion), then falls back to string comparison.
(a: &serde_json::Value, b: &serde_json::Value)
| 27 | /// Tries numeric comparison first (with bool coercion), then falls |
| 28 | /// back to string comparison. |
| 29 | pub fn compare_json(a: &serde_json::Value, b: &serde_json::Value) -> Ordering { |
| 30 | // Try numeric comparison with bool coercion. |
| 31 | if let (Some(na), Some(nb)) = (json_to_f64(a, true), json_to_f64(b, true)) { |
| 32 | return na.partial_cmp(&nb).unwrap_or(Ordering::Equal); |
| 33 | } |
| 34 | // Fallback: string comparison. |
| 35 | let sa = json_to_display_string(a); |
| 36 | let sb = json_to_display_string(b); |
| 37 | sa.cmp(&sb) |
| 38 | } |
| 39 | |
| 40 | /// Compare two optional JSON values (for scan_filter compatibility). |
| 41 | pub fn compare_json_optional( |
no test coverage detected