I currently have a python function that goes through a json and returns the keys as a list of lists. For example, if a json was like
{'employee':{ 'info':{'name':'bob' , 'id':4 }, 'department':{'name':'sales' , 'floor':1}}}
it would return a list like
[[['employee'], ['info'], ['name']], [['employee'], ['info'], ['id']], [['employee'], ['department'], ['name']], [['employee'], ['department'], ['floor']]] .
If I wanted to look up, for example, the employees name, is there a way I could reference the list to make its corresponding entry from a list of lists into something like
json['employee']['info']['name']?
https://stackoverflow.com/questions/66897815/how-would-i-use-a-list-of-lists-containing-the-keys-of-a-json-to-reference-value April 01, 2021 at 10:50AM
没有评论:
发表评论