Python - Converting Arrays to Dict Hierarchy
We are talking about converting different data arrays into Python dictionaries.
Here is an example of converting a Set into a Dict Hierarchy
import json
dataset = {"root", "sport", "football"}
datadict = dict()
for key in reversed(dataset):
datadict = {key: datadict}
print(json.dumps(datadict, indent=4))
Output:
{
"root": {
"sport": {
"football": {}
}
}
}