Comparing XML/JSON files

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

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@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@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk

you can use powershell for Linux. this capability is built in On Mon, Dec 6, 2021 at 3:48 PM William Park via talk <talk@gtalug.org> wrote:
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@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk

PowerShell? I'm reading Microsoft doc site... read... scratch head... read... few 4 letter words... lots of 4 letter words... --William On 12/6/21 7:09 PM, Ansar Mohammed via talk wrote:
you can use powershell for Linux. this capability is built in
On Mon, Dec 6, 2021 at 3:48 PM William Park via talk <talk@gtalug.org <mailto:talk@gtalug.org>> wrote:
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@gtalug.org <mailto:talk@gtalug.org> Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk
--- Post to this mailing list talk@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk

On Mon, Dec 06, 2021 at 11:06:36PM -0500, William Park via talk wrote:
PowerShell? I'm reading Microsoft doc site... read... scratch head... read... few 4 letter words... lots of 4 letter words...
Supposedly very powerful, but looks like someone took the windows api and made it a CLI. Horrible syntax. :) So it can do lots of stuff if you can figure out how to ask it. -- Len Sorensen

I don’t mind doing a demo of powershell on Linux. It’s open source of course :) On Tue, Dec 7, 2021 at 8:04 AM Lennart Sorensen via talk <talk@gtalug.org> wrote:
On Mon, Dec 06, 2021 at 11:06:36PM -0500, William Park via talk wrote:
PowerShell? I'm reading Microsoft doc site... read... scratch head... read... few 4 letter words... lots of 4 letter words...
Supposedly very powerful, but looks like someone took the windows api and made it a CLI. Horrible syntax. :)
So it can do lots of stuff if you can figure out how to ask it.
-- Len Sorensen --- Post to this mailing list talk@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk
participants (4)
-
Ansar Mohammed
-
Lennart Sorensen
-
Mauro Souza
-
William Park