How do I pull out the key in a nested dictionary of unknown length and equate that key to the traversal path and store them as a key value pair in another dictionary. I have a nested dictionary as below
{
"ingestion_config": {
"location": {},
"start_sequence": {},
"datafeed": {
"t04047": {
"validation": {
"triple_check": {},
"record_count_validation": {}
},
"date_pattern": {},
"cdc_config": {}
}
}
}
}
I am looking to fetch the keys at various levels and equate it the traversal path as below
{
ingestion_config: [ingestion_config]
location: [ingestion_config][location],
start_sequence: [ingestion_config][start_sequence],
datafeed: [ingestion_config][datafeed]
t04047: [ingestion_config][datafeed][t04047]
triple_check: [ingestion_config][data_feed][t04047][validation][trip_check]
}
The closest post I have found for a scenario similar to mine is: here