Last Updated: February 25, 2016
· abhikandoi2000

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 | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["'a'"]';

Note: the above command actually works