Put the following snip to your vimrc, whenever you open a JSON file, you can format it with hotkey fj in normal mode.
function FmtJSON(...) |
The main part of function FmtJSON is copied from somewhere, but if the JSON file is malformed you probably override the original file unexpectedly, so I added try-catch in the end event handler.