Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created May 22, 2013 15:06
Show Gist options
  • Select an option

  • Save dotemacs/5628302 to your computer and use it in GitHub Desktop.

Select an option

Save dotemacs/5628302 to your computer and use it in GitHub Desktop.
;; clean this up and 'package it' nicely
(defun beautify-json ()
"taken from jstevenco http://stackoverflow.com/revisions/7934783/2"
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
(shell-command-on-region b e
;; "python -c 'import sys,json; data=json.loads(sys.stdin.read()); print json.dumps(data,sort_keys=True,indent=4).decode(\"unicode_escape\").encode(\"utf8\",\"replace\")'"
;; (current-buffer) t)))
"~/bin/jsonfmt" (current-buffer) t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment