linux 利用python模块实现格式化json

非json格式示例

{"name": "chen2ha", "where": {"country": "China", "info": {"age": "27", "birthday": "1995-03-20", "body": {"sex": "gentleman", "style":"tie han han"}}}}

在 vim 中

:%!python -m json.tool

在这里插入图片描述

在命令行终端

python -m json.tool test.json
{
    "name": "chen2ha",
    "where": {
        "country": "China",
        "info": {
            "age": "27",
            "birthday": "1995-03-20",
            "body": {
                "sex": "gentleman",
                "style": "tie han han"
            }
        }
    }
}
posted @ 2022-02-19 23:33  月巴左耳东  阅读(63)  评论(0编辑  收藏  举报