How can I pretty-print JSON in a shell script?

后端 未结 30 2971
孤独总比滥情好
孤独总比滥情好 2020-11-22 16:27

Is there a (Unix) shell script to format JSON in human-readable form?

Basically, I want it to transform the following:

{ \"foo\": \"lorem\", \"bar\":         


        
30条回答
  •  遥遥无期
    2020-11-22 17:12

    If you use npm and Node.js, you can do npm install -g json and then pipe the command through json. Do json -h to get all the options. It can also pull out specific fields and colorize the output with -i.

    curl -s http://search.twitter.com/search.json?q=node.js | json
    

提交回复
热议问题