Emacs mode to edit JSON

后端 未结 12 1886
面向向阳花
面向向阳花 2021-01-30 12:15

Does anybody know a good Emacs mode to edit JSON? An app I am working on uses a JSON based communication protocol and having the data nicely indented and syntax-highlighted woul

12条回答
  •  耶瑟儿~
    2021-01-30 12:50

    I will also second Josh's json-mode, but also recommend flymake-json as an addition. It helps highlight syntax errors.

    I don't like using python -mjson.tool because it reorders items in JSON objects. I find (prog-indent-sexp) works just fine to reindent, and using jsonlint instead of python -mjson.tool works for pretty printing/reformatting in beautify-json

    (eval-after-load "json-mode"
      '(progn
         (require 'flymake-json)
         ;; flymake-cursor displays error in minibuffer message area instead of requiring hover
         (require 'flymake-cursor)
    
         (add-hook 'json-mode-hook 'flymake-json-load)
         (define-key json-mode-map "\C-c\C-n" (function flymake-goto-next-error))
      )
    )
    

提交回复
热议问题