Posted by & filed under Open-source. 14,556 views

Place it in .git/hooks in your git source controlled directory

git diff-index -z --cached HEAD --name-only --diff-filter=ACMRTUXB |
xargs -0 -t -L1 /usr/local/bin/jsonlint -c;

if [ "$?" != "0" ]; then
echo "\nOne or more JSON file didn't pass jsonlint'ing.";
echo "Fix them before committing. If it is not possible to fix them all commit with the option --no-verify.";

exit 1;

This works on a mac. xargs is a little bit different on linux where it probably should be changed to xargs --null --no-run-if-empty /usr/local/bin/jsonlint -c;.
This assumes jsonlint is installed in /usr/local/bin

The gist can be found here.