jq is a lightweight and flexible command-line JSON processor.
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
jq-1.4-i486-1_SBo.tgz
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 # output 3 { 4 "keyx": 55, 5 "keyz": "otherVal" 6 }
1 jq '.keyx' test.json 2 # output 3 12