Topwo博客
首页
博客
项目
您现在的位置是:
Topwo博客
>>
其他
文章
shell里读取Json数据
发布时间:2021-09-27
作者:Topwo
来源:原创
点击:321
#### 推荐python方法,通过引用python方法来更方便的解析。 ### 一、json字符串 ```shell echo '{"hostname":"test","domainname":"example.com"}' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[0]["hostname"]' ``` ### 二、json文件 ```shell cat file.json | python -c "import json; import sys; obj=json.load(sys.stdin); print obj['province'][1]['name'].encode('utf-8')" ```
上一篇:
shell如何使目录下的文件按文件大小排序
下一篇:
shell数组和字典