Bug#839538: diffoscope: json: detect order-only differences

Daniel Shahaf danielsh at apache.org
Sat Oct 1 17:23:42 UTC 2016


Source: diffoscope
Version: 60
Severity: wishlist
Tags: upstream

Dear Maintainer,

When two json files differ only in order of elements, diffoscope falls
back to binary comparison:

[[[
% head -999 /tmp/?.json
==> /tmp/1.json <==
{
  "hello": 42,
  "world": 43
}

==> /tmp/2.json <==
{
  "world": 43,
  "hello": 42
}

% trydiffoscope $_
--- a/1.json
+++ b/2.json
│┄ No file format specific differences found inside, yet data differs
│ @@ -1,3 +1,3 @@
│ -00000000: 7b0a 2020 2268 656c 6c6f 223a 2034 322c  {.  "hello": 42,
│ -00000010: 0a20 2022 776f 726c 6422 3a20 3433 0a7d  .  "world": 43.}
│ +00000000: 7b0a 2020 2277 6f72 6c64 223a 2034 332c  {.  "world": 43,
│ +00000010: 0a20 2022 6865 6c6c 6f22 3a20 3432 0a7d  .  "hello": 42.}
│  00000020: 0a                                       .%
]]]

It would be better to report "json files are equal up to order of
elements in an object (= hash, dictionary, associative array)", and to
print the difference in a more readable way than a hex dump.  (For
example, a linewise diff of pretty-printed json.)

Cheers,

Daniel



More information about the Reproducible-builds mailing list