Created
April 2, 2017 16:51
-
-
Save mirskiy/773bb250470250ecea1453f0f03c00b4 to your computer and use it in GitHub Desktop.
Diff json with vimdiff
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
# Add this to your .bashrc or .bash_aliases | |
jdiff() { | |
# Diff json files faster | |
# Uses python json.dump with sort_keys=True to fix ordering, then vimdiff | |
if [[ $# -ne 2 ]]; then | |
echo "syntax: jdiff file1 file2" | |
return | |
fi | |
py3 -c "import json; json.dump(json.load(open('$1')), open('/tmp/jdiff.1', 'w'), indent=4, sort_keys=True)" | |
py3 -c "import json; json.dump(json.load(open('$2')), open('/tmp/jdiff.2', 'w'), indent=4, sort_keys=True)" | |
vimdiff /tmp/jdiff.{1,2} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment