本文主要是介绍linux下格式化json,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
有时候有一个json的字符串不容易清晰的查看
例如:
[root@aliyun ~]# cat a
{"openid":"o-U6bs4yPp1pQB1eTdbXxuFp4v5Y","nickname":"郭新鹏","sex":1,"language":"en","city":"海淀","province":"北京","country":"中国","headimgurl":"http:\/\/wx.qlogo.cn\/mmopen\/DU8c6WuxXjdzqOliauibrW0Qz3fKa1pj8vFyfNFvrUPial0IVFBC6XzNUKkPTG71aNjDqjb4ZIHHQ0wicGmw8bvhwY7ebKePEicnE\/0","privilege":[],"unionid":"o1GCawQURlBzS_wHVheBxNwp2IFk"}
[root@aliyun ~]# cat a | jq .
{"openid": "o-U6bs4yPp1pQB1eTdbXxuFp4v5Y","nickname": "郭新鹏","sex": 1,"language": "en","city": "海淀","province": "北京","country": "中国","headimgurl": "http://wx.qlogo.cn/mmopen/DU8c6WuxXjdzqOliauibrW0Qz3fKa1pj8vFyfNFvrUPial0IVFBC6XzNUKkPTG71aNjDqjb4ZIHHQ0wicGmw8bvhwY7ebKePEicnE/0","privilege": [],"unionid": "o1GCawQURlBzS_wHVheBxNwp2IFk"
}
安装jq即可
yum install jq
这篇关于linux下格式化json的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!