Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: d1717de22c
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (28 sloc) 1.15 KB
;;; json-mode.el --- major mode for editing JSON files
;;; - extends javascript mode to add better syntax highlighting
;; syntax highlighting
(defvar json-mode-hook nil)
(defconst json-quoted-key-re "\\(\"[^\"]+?\"[ ]*:\\)")
(defconst json-quoted-string-re "\\(\".*?\"\\)")
(defconst json-int-re "\\([^\"][0-9]+[^\"]\\)")
(defconst json-keyword-re "\\(true\\|false\\|null\\)")
(defconst json-font-lock-keywords-1
(list json-quoted-key-re 1 font-lock-keyword-face)
(list json-quoted-string-re 1 font-lock-string-face)
(list json-keyword-re 1 font-lock-constant-face)
(list json-int-re 1 font-lock-constant-face)
"Level one font lock.")
(defun beautify-json ()
(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 -mjson.tool" (current-buffer) t)))
(define-derived-mode json-mode javascript-mode "JSON"
"Major mode for editing JSON files"
(set (make-local-variable 'font-lock-defaults) '(json-font-lock-keywords-1 t)))
(define-key json-mode-map (kbd "C-c C-f") 'beautify-json)
(provide 'json-mode)
Jump to Line
Something went wrong with that request. Please try again.