Order-aware comparison of two JSON values. Unlike `JsonValue::eq`, this treats objects with different key order as different, matching serialisation behaviour.
(a: &JsonValue, b: &JsonValue)
| 984 | /// treats objects with different key order as different, matching |
| 985 | /// serialisation behaviour. |
| 986 | fn json_values_differ(a: &JsonValue, b: &JsonValue) -> bool { |
| 987 | match (a, b) { |
| 988 | (JsonValue::Object(a), JsonValue::Object(b)) => { |
| 989 | a.len() != b.len() |
| 990 | || a |
| 991 | .iter() |
| 992 | .zip(b.iter()) |
| 993 | .any(|((k1, v1), (k2, v2))| k1 != k2 || json_values_differ(v1, v2)) |
| 994 | } |
| 995 | (JsonValue::Array(a), JsonValue::Array(b)) => a.len() != b.len() || a.iter().zip(b.iter()).any(|(a, b)| json_values_differ(a, b)), |
| 996 | _ => a != b, |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | /// Get-or-create the child mapping at `key`, replacing any non-mapping value |
| 1001 | /// already there. The returned reference borrows `map`. |
no outgoing calls
no test coverage detected
searching dependent graphs…