How can I pretty-print a JSON file from the command line?

后端 未结 13 1834
星月不相逢
星月不相逢 2020-12-07 14:32

I\'ve a file with a sequence of JSON element:

{ element0: \"lorem\", value0: \"ipsum\" }
{ element1: \"lorem\", value0: \"ipsum\" }
...
{ elementN: \"lorem\"         


        
13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 15:22

    Colored output using Pygmentize + Python json.tool

    Pygmentize is a killer tool. See this. I combine python json.tool with pygmentize

    echo '{"foo": "bar"}' | python -m json.tool | pygmentize -g
    

    For other similar tools and installation instruction see the answer linked above.

    Here is a live demo:

提交回复
热议问题