Working with json objects and json files

How to prettify json content?

https://emacs.stackexchange.com/questions/12148/how-to-pretty-format-code-auto-insert-newlines-indent-etc

I have a JSON file with a single long line. How can we indent this?

{"menu": {"id": "file", "value": "File", "popup": {"menuitem": [{"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"}]}}}
  1. In emacs, select the text and do M-x json-pretty-print
  2. If the file is a json file, we can use M-x json-pretty-print-buffer

Tags

  1. How to validate Json files?

Links to this note