
1、JSON命令:
$ wget http://stedolan.github.io/jq/download/linux32/jq (32-bit system) $ wget http://stedolan.github.io/jq/download/linux64/jq (64-bit system) $ chmod +x ./jq $ cp jq /usr/bin1.2.3.4.
2、JSON Schema:
json.txt
{
"name": "Google",
"location":
{
"street": "1600 Amphitheatre Parkway",
"city": "Mountain View",
"state": "California",
"country": "US"
},
"employees":
[
{
"name": "Michael",
"division": "Engineering"
},
{
"name": "Laura",
"division": "HR"
},
{
"name": "Elise",
"division": "Marketing"
}
]
}
3、解析JSON object:
$ cat json.txt | jq '.name' "Google"
4、解析嵌套的JSON对象:
$ cat json.txt | jq '.location.city' "Mountain View"
5、解析JSON数组:
$ cat json.txt | jq '.location | {street, city}'
{
"city": "Mountain View",
"street": "1600 Amphitheatre Parkway"
}
以上就是为各位朋友分享的相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多等着你!


微信扫一扫打赏
支付宝扫一扫打赏
