What is the simplest way to access a field in json data if entire key-address is given in a list.
E.g., Given "data" a json object and ["context", "body", "gk"]
as the list of keys, i.e.
resultant value = data["context"]["body"]["gk"]
In this, list of keys can be of any length.
Is there any simpler approach to this?
target = json.loads(data)
for elem in key_list:
target = target[elem]
print target