milegg
Last Updated: February 25, 2016
·
2.263K
· abhikandoi2000
B7b49831b9a1e3f260d412488bbda9f8

Extract a value from a JSON endpoint in bash

Curl the URL to get the JSON response and pipe it to the python tool. The python code will extract the value mapped to the given key (a in this case).

curl -s https://raw.githubusercontent.com/popomore/father/c4e46479b7ea59de8dbbdf2be9a39dee3b3431c6/test/fixtures/spm/require-priority/a.json | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["'a'"]';

Note: the above command actually works

Say Thanks
Respond