Supports nested dict, list within a dict
Usage Example:
data = {
'name': 'Hassan',
'detail': {
'country': 'Pakistan',
'hobbies': [
'cricket',
'gaming'
]
}
}
print(dict_deep_get(data, 'name')) # Hassan
print(dict_deep_get(data, 'detail.country')) # Pakistan
print(dict_deep_get(data, 'detail.hobbies.1')) # gaming
print(dict_deep_get(data, 'detail.city')) # None
print(dict_deep_get(data, 'detail.hobbies.2', 'N/A')) # N/A
The time complexity of this function is O(n) where n is the number of iterations. Space complexity is O(1)