遇到要在Linux上处理json的请求,换了熟悉的环境就抓瞎了,需要用心学习基础知识。
jq官网:https://stedolan.github.io/jq
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
时间: 2024-12-28 23:22:24