I'm parsing a json
-> dict
object that has values nested at arbitrary depths. For example, the outer level are the fields (the data is from a customer service ticketing system) such as 'name', 'sprint_team', etc... But then for some fields they have a nested dict
that will have values like 'id', 'value', etc...
I'm pulling it all down to place in a flat file to then copy over to AWS Redshift, but I'm trying to figure out an efficient way to handle all the different nested levels of values I might need. I was thinking of using a lookup table such as:
lookup = {
'customfield_12700': ('sprint_team', 'name'),
'customfield_13208': ('department', 'sub_department', 'name')
}
where the value[0]
is always the lookup name, and then there can be n number of extra params that will be my levels of nesting. The reason I'm using a lookup table in the first place is because Jira uses customfields, and I need to map them to the column names in our cloud database. For example, on the sprint_team
field I need the name
attribute for my flat file, etc...
How could I create a function that will take a dictionary object, and then use the lookup table to return the value I need, regardless of how deeply nested it is?