I want to parse in bash the json-string like this:
{"710":{"sysKey":"ENTER"},"230":{"sysKey":"DELETE"},"804":{"sysKey":"ADD"}}
My task is to find the value of key {"sysKey":"DELETE"} and get 230
My try:
echo '{"710":{"sysKey":"ENTER"},"230":{"sysKey":"DELETE"},"804":{"sysKey":"ADD"}}' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["sysKey"]["DELETE"];'
Help me please!
230is the key not the value. You can't lookup by value. You need to walk for values. So you get to walk all the values looking for a value that is a dictionary with asysKeykey that hasDELETEas its value.jqutility. stackoverflow.com/questions/18592173/…