For the task at hand, the version using keys should be used. POST-POSTSCRIPT: The builtin version of walk has recently been changed so that it no longer sorts the keys within an object. $JQ -r -n -argfile A "$1" -argfile B "$2" -f 1.5, and can therefore be omitted if your jq includes it, but there is no harm in including it redundantly in a jq script. ( )Īnd wrapped up as a bash script: #!/bin/bash Here is a solution using the generic function walk/1: # Apply f to composite entities recursively, and to atoms r def post_recurse: post_recurse(.?) ($a | (post_recurse | arrays) |= sort) as $a | ($b | (post_recurse | arrays) |= sort) as $b | $a = $b' r def post_recurse: post_recurse(.?) (post_recurse | arrays) |= sortĪpplied to the jq invocation above: jq -argfile a a.json -argfile b b.json -n 'def post_recurse(f): def r: (f | select(. This GitHub issue explains why and provides some alternatives, such as: def post_recurse(f): def r: (f | select(. | arrays) |= sort construct doesn't actually work as expected on some edge cases. This program should return "true" or "false" depending on whether or not the objects are equal using the definition of equality you ask for.ĮDIT: The (. Assuming your two files are named a.json and b.json, on the latest jq nightly: jq -argfile a a.json -argfile b b.json -n '($a | (. See our information on translating WinMerge into your own language.Since jq's comparison already compares objects without taking into account key ordering, all that's left is to sort all lists inside the object before comparing them. In addition, WinMerge is translated into a number of different languages. WinMerge is an open source project, which means that the program is maintained and developed by volunteers. If you need support, look at our support page for more information how you can get it. WinMerge 2.16.28 is the latest stable version, and is recommended for most users.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |