jq
jq is a lightweight and flexible command-line JSON processor.
Slackbuild
1 cd /tmp
2 wget https://slackbuilds.org/slackbuilds/14.2/system/jq.tar.gz
3 tar xvzf jq.tar.gz
4 cd jq
5 wget https://github.com/stedolan/jq/releases/download/jq-1.4/jq-1.4.tar.gz
6 ./jq.SlackBuild
7 installpkg /tmp/jq-1.4-i486-1_SBo.tgz
Change values
test.json
1 {
2 "keyx":12,
3 "keyz":"ddff"
4 }
test2.json
1 {
2 "keyx":12,
3 "keyz":"ddff",
4 "arr":[1,2,3,4]
5 }
1 jq '.keyx = 55 | .keyz = "otherVal"' test.json
2
3 {
4 "keyx": 55,
5 "keyz": "otherVal"
6 }
Get value from key
1 jq '.keyx' test.json
2
3 12
jq (last edited 2018-06-14 22:10:13 by localhost)