(a: &serde_json::Value, b: &serde_json::Value)
| 44 | } |
| 45 | |
| 46 | fn compare_json(a: &serde_json::Value, b: &serde_json::Value) -> std::cmp::Ordering { |
| 47 | use serde_json::Value; |
| 48 | match (a, b) { |
| 49 | (Value::Null, Value::Null) => std::cmp::Ordering::Equal, |
| 50 | (Value::Null, _) => std::cmp::Ordering::Less, |
| 51 | (_, Value::Null) => std::cmp::Ordering::Greater, |
| 52 | (Value::Bool(x), Value::Bool(y)) => x.cmp(y), |
| 53 | (Value::Number(x), Value::Number(y)) => x |
| 54 | .as_f64() |
| 55 | .partial_cmp(&y.as_f64()) |
| 56 | .unwrap_or(std::cmp::Ordering::Equal), |
| 57 | (Value::String(x), Value::String(y)) => x.cmp(y), |
| 58 | _ => a.to_string().cmp(&b.to_string()), |
| 59 | } |
| 60 | } |
no test coverage detected