Last active
December 11, 2015 02:09
-
-
Save JoshuaGross/800c7f94899f928443fc to your computer and use it in GitHub Desktop.
Sort JSON to make it easier to diff two JSON blobs by normalizing whitespace, alphabetization of dictionaries.
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
# Install: | |
npm install -g sort-json | |
# Put this in your ~/.profile, and then: | |
# cat something.json | normalize_json | |
alias normalize_json="node -e 'var s = \"\"; process.stdin.on(\"data\", function (d) { s += d.toString(); }); process.stdin.resume(); process.on(\"exit\", function() { console.log(JSON.stringify(require(\"sort-json\")(JSON.parse(s)), null, 2)); });'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment