code_junkie

Emacs mode to edit JSON

Nov 13th, 2011
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. (defun beautify-json ()
  2. (interactive)
  3. (let ((b (if mark-active (min (point) (mark)) (point-min)))
  4. (e (if mark-active (max (point) (mark)) (point-max))))
  5. (shell-command-on-region b e
  6. "python -mjson.tool" (current-buffer) t)))
  7.  
  8. (define-key json-mode-map (kbd "C-c C-f") 'beautify-json)
  9.  
  10. var myJSObject = {
  11. attr: {foo: "bar", baz: ["quux", "truc", "pouet"]},
  12. fooAlert: function (num) {
  13. alert(this.attr.foo+' '+num);
  14. }
  15. };
  16. myJSObject.fooAlert(42);
Add Comment
Please, Sign In to add comment