Skip to navigation
Parse json with bash
12.03.18
use jq 1. apt-get install jq bash example: _rev=$(curl -H "Accept: application/json" -H "Authorization: Basic $BASE64" -H "Content-Type: application/json" -s 'http://127.0.0.1:5984/_users/org.couchdb.user:foo' | jq -r '._rev' ) echo $_rev
http://www.compciv.org/recipes/cli/jq-for-parsing-json/
Reply
Anonymous
Example to get the JSON data file into bash variables file: token.json: {"token_type":"bearer","expires_in":2881,"refresh_token":"f2c9161da134562049618882bf2e9acb","access_token":"1927c2dcc2a42b1e8333339882cff"} access_token=$(cat token.json | jq -r '.access_token') refresh_token=$(cat token.json | jq -r '.refresh_token') expires_in=$(cat token.json | jq -r '.expires_in') token_type=$(cat token.json | jq -r '.token_type')
12.03.18
Reply
Anonymous
Information Epoch 1753624653
Make every program a filter.
Home
Notebook
Contact us