Let's look at what we have at our disposal to work with json in Emacs, both such as a user (editing json files) and as an elisp developper.
- 1 Editing and working in json files
- 2 Development
- 3 See also
Editing and working in json files
- syntax highlighting and indentation,
- format the region or buffer, with json-reformat. Bound to
- display the path of the object at point, with json-snatcher. Bound to
It actually inherits from js-mode to add better syntax highlighting for JSON.
Starting from Emacs 24.4 we have the built-in commands
Anyways there also is the json-reformat package, in MELPA.
js-beautify package on the npm registry.
See also flycheck-demjsonlint to be able to specify linting rules.
json-navigator (in MELPA, for Emacs >= 25.1 only) allows to display any JSON document as a tree, which leafs you can unfold and follow.
It is an example of the hierarchy project.
json-snatcher - get the path of a json element
Parsing and generating json
With the built-in json.el library.
Request json content
See request.el that allows to request content to http endpoints and parse the result to json.
Using js2-mode functions
We could also use js2-mode functions, even when the mode itself isn't activated. We then have
js2-print-json-path at our disposal as an alternative to
json-snatcher. See the custom function on redguardtoo's blog post.