Ok, json_tree is a variable that contains something that looks like this:
json_tree = "['time']['updated']"
Can you pass it as a variable....
hdr = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' }
req = urllib.request.Request(url, headers=hdr)
readdata = urllib.request.urlopen(req)
json_data = readdata.read()
json_dict = json.loads(json_data)
like so??
print(json_dict[json_tree])
My purpose is to pass one of many json_tree values from a .ini into the class that contains the above code. If this is a bad plan, what could work, instead?
Thank you!
This is a use case for
jsonpath
, in which syntax one would use the expressiontime.updated
to refer to the value in question.