样例:
{"IP":"192.168.10.100",
"Prod":"5000",
"fy_tp_hellowrd_service":[
{
"Ip":"192.168.10.101",
"Prod":"5001",
"Service":"fy_tp_hellowrd_service"
},
{
"Ip":"192.168.10.102",
"Prod":"5002",
"Service":"fy_tp_hellowrd_service2"
}
]
} 第一步安装jq
yum -y install jq
第二部获取IP:192.168.10.100
cat service-info.json |jq '.IP' 获取到的IP是带有双引号的
"192.168.10.100"
去掉双引号
cat service-info.json |jq '.IP'| sed s/\"//g | head
第三步获取 IP 192.168.0.102
cat service-info.json |jq '.fy_tp_hellowrd_service[1].Ip'| sed s/\"//g | head
注意【】这里是第几个组里面的数据 默认从0开始
好的谢谢大家查看 标签:service,IP,jq,192.168,json,tp,解析 From: https://www.cnblogs.com/litl/p/16984627.html