Created
February 28, 2013 01:21
-
-
Save re5et/5053399 to your computer and use it in GitHub Desktop.
This file contains 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
(defun prettify-json () | |
"NOTE: requires ruby in $PATH. Replace a valid json region with | |
pretty printed json By default uses the jj method to print, | |
uses pp if there is a prefix argument" | |
(interactive) | |
(let* ((print-method (if current-prefix-arg "pp" "jj")) | |
(cmd (format | |
"ruby -e 'require \"json\"; require \"pp\"; %s JSON.parse(gets)'" print-method))) | |
(shell-command-on-region | |
(region-beginning) | |
(region-end) | |
cmd nil t))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can also: