Python script to return json value for given key

Sometimes on some systems there is no awk and no jq. Hopefully there is python.
When we need the value from a key in a json file, we could use this:

variable=`cat file.json | python -c "import json,sys;obj=json.load(sys.stdin);print obj['name'];"`

Comments