I want to split two JSON text files. Unfortunately, they are built in random order, so I get diff when they are semantically identical. I would like to use jq (or something else) to sort them in any order in order to eliminate differences related only to the ordering of the elements.
- sort keys solve half the problem, but don't sort arrays.
I am pretty versed in jq and donโt know how to write a recursive jq filter that saves all the data; Any help would be appreciated.
I understand that line output of "diff" is not always the best way to compare two complex objects, but in this case I know that the two files are very similar (almost identical) and in turn diffs are good for my purposes.
Using jq or alternative command line tools to delimit JSON files answers a very similar question, but does not print the difference. Also, I want to save the sorted results, so what I really want is just a filtering program to sort JSON.
source share