Created
October 9, 2020 15:38
-
-
Save murrahjm/14dbf530f929f7b21732ee3a41402f88 to your computer and use it in GitHub Desktop.
using jq to sort two json files for comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jq --argfile a file1.json -n 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); ($a | (post_recurse | arrays) |= sort)' > fmt_file1.json | |
jq --argfile a file2.json -n 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); ($a | (post_recurse | arrays) |= sort)' > fmt_file2.json | |
diff -ZEB <(jq -S . fmt_file1.json) <(jq -S . fmt_file2.json)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment