[GTALUG] Comparing XML/JSON files

Mauro Souza thoriumbr at gmail.com
Mon Dec 6 18:49:52 EST 2021


I don't think there are any "one-shot" alternatives to that. And even
jsondiff would say the files are different even if they are essentially the
same but the objects are in a different order.

For example, jsondiff (the site) says that
    [{"a": "b", "b": "a"},{ "value": 1, "name": "x"}]
and
    [{"name": "x", "value": 1},{"a": "b", "b": "a"}]

are different. Depending on your point of view, they are the same.

If you don't care about the order of the objects nor the order of the
properties, you will have to write your own comparator.


Mauro
https://www.maurosouza.com - registered Linux User: 294521
Scripture is both history, and a love letter from God.


Em seg., 6 de dez. de 2021 às 17:48, William Park via talk <talk at gtalug.org>
escreveu:

> Hi all,
>
> I know of "xmldiff" and "jsondiff" to compare XML or JSON files.  But,
> they don't allow me to exclude certain node or keyword.  Do you know any
> command line program that does that, in one-shot?
>
> If not, then I have to resort to
>      1. For JSON, use 'jq' to remove keyword, and then compare.
>      2. For XML, use 'xmlstarlet' to remove node, and then compare.
>
> --William
> ---
> Post to this mailing list talk at gtalug.org
> Unsubscribe from this mailing list
> https://gtalug.org/mailman/listinfo/talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/talk/attachments/20211206/40b1e036/attachment.html>


More information about the talk mailing list