2012年3月4日 星期日

Parse json text via shell command

Let say you have a long json output and it is pretty hard to read.

$ cat json-example.txt
{"email":"user@domain.com","display_name":"Email user","name":"user","key_id":"ajkazGNjgjj33122k22","key_secret":"shjajajaj8AzgjgnG3ooppkajzn3","id":"a81290zkgjgnzmGffs13AgkzzpGgz"}



You could then use python json module to decode the json output and makes it readable.


$ cat json-example.txt  | python -mjson.tool
{
    "display_name": "Email user",
    "email": "user@domain.com",
    "id": "a81290zkgjgnzmGffs13AgkzzpGgz",
    "key_id": "ajkazGNjgjj33122k22",
    "key_secret": "shjajajaj8AzgjgnG3ooppkajzn3",
    "name": "user"
}

沒有留言:

張貼留言