JSON

JSON (JavaScript Object Notation) is a subset of JavaScript useful as a format for transferring data from program to program, much like XML.

Read all about it at json.org!

You can decode and encode JSON from Emacs Lisp using json.el. It is part of GNU Emacs since 23.1 (2008).

json-mode

Some highlighting support for editing json files is provided by json-mode.

If you have python or jsonlint installed, Flycheck can report errors in json-mode, just do:

  (add-hook 'json-mode-hook #'flycheck-mode)

(jsonlint can give schema-based validation, but the python-based validator is handy too for simply catching missing commas etc.)

formatting by hand

https://github.com/gongo/json-reformat mentions that Emacs 24.4+ has built-in json-pretty-print and json-pretty-print-buffer functions.

As https://irreal.org/blog/?p=354 wrote, you can also simply

   C-u M-| python -m json.tool

to reformat a buffer containing JSON.


CategoryData CategoryExtensions CategoryJavaScript