i have for loops running on the multiple levels . Each level of loop returns a json which needs to be put in a hierarchy .
output = {}
for a in alist:
aid, ajson = hit_api(url1)
output[aid] = ajson
for b in blist:
bid, bjson = hit_api(url2)
output[aid][bid] = bjson -- this is where we are getting error
The error is as below
Traceback (most recent call last):
File "Test.py", line 80, in <module>
output[aid][bid] = bjson
TypeError: 'unicode' object does not support item assignment
We need to create a final json with nested hierarchy based on the for loop. something like
aid:ajson
|
---bid:bjson
|
--- cid:cjson
|
etc.