且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux中解析json---jq

更新时间:2022-09-18 15:06:29

1.install
 
yum install jq
在公司的centos6.3上这样安装成功了,然而自己电脑7.5安装失败,采用源码安装
 
git clone https://github.com/stedolan/jq.git
cd jq
autoreconf -i
./configure --disable-maintainer-mode
make
sudo make install
 
2.test
 
cd /temp
vim json_test.json
{"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"}]}
cat json_test.json | jq .
cat json_test.json | jq.name
 
本文转自Ryan.Miao博客园博客,原文链接:http://www.cnblogs.com/woshimrf/p/5503152.html,如需转载请自行联系原作者