JSON command line formatter tool for Linux [closed]
Solution 1:
alias pp='python -mjson.tool'
pp mydata.json
From the first link in the accepted answer: http://ruslanspivak.com/2010/10/12/pretty-print-json-from-the-command-line/
Solution 2:
jq is a lightweight and flexible command-line JSON processor.
http://stedolan.github.io/jq/
jq is like sed for JSON data – you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.
jq is written in portable C, and it has zero runtime dependencies. You can download a single binary, scp it to a far away machine, and expect it to work.
Solution 3:
On Ubuntu jsonlint is provided by apt:python3-demjson
Usage:
$ sudo apt install -y python3-demjson
$ jsonlint -f input.json > output.json
Solution 4:
Add to vimrc:
" Format JSON data
map <C-F6> :%!python -m json.tool<CR>
And you can use the shortcut CTRL+F6 to format json data
Or just under vim's command mode:
%!python -m json.tool