shell 命令行中格式化输出 JSON

更新日期: 2018-03-07 阅读次数: 19421 分类: 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
}

微信关注我哦 👍

大象工具微信公众号

我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式