MCPcopy Create free account
hub / github.com/JamieMason/syncpack / json_values_differ

Function json_values_differ

src/disk.rs:986–998  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

984/// treats objects with different key order as different, matching
985/// serialisation behaviour.
986fn 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`.

Callers 2

set_propFunction · 0.85
set_nested_propFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…