shell 命令行中格式化输出 JSON

更新日期: 2018-03-07 阅读次数: 1071 分类: Shell

echo '<raw_json>' | python -mjson.tool

example:

echo '{"msg": "ok", "data": {"list": [{"website": "letv", "url": "http://www.letv.com/ptv/pplay/75420/2.html", "video_id": "1594024"}], "cover": "http://img0.hao123.com/data/1_410778331e67b59a079ce4f802fcb26d"}, "ret": 0}' | python -mjson.tool
{
    "data": {
        "cover": "http://img0.hao123.com/data/1_410778331e67b59a079ce4f802fcb26d",
        "list": [
            {
                "url": "http://www.letv.com/ptv/pplay/75420/2.html",
                "video_id": "1594024",
                "website": "letv"
            }
        ]
    },
    "msg": "ok",
    "ret": 0
}

爱评论不评论