fork download
  1. resp={
  2. "A" : {
  3. "uni" :
  4. [
  5. {
  6. "Name" : "cc",
  7. "Id" : "1",
  8. },
  9. {
  10. "Name" : "cc",
  11. "Id" : "1",
  12. }
  13. ]
  14. }
  15. }
  16.  
  17. for key, value in resp["A"].items():
  18. print(1, key)#this key is the "uni/aa/bb" value that may change
  19. print(2,resp["A"][key][0]) #the object that is present in the array, so after each iteration the item object will change, that is first object in the array then second object in the array and so on
  20. print(3,resp["A"][key][0]["Name"])# and now are accessing the Name project of that object
  21. for item in resp["A"][key]:
  22. print(4,item) #same as above but we looping through the object that is received through `key` variable index
  23. print(5,item["Name"])# same "Name" object but we are looping though all the items in the array
  24.  
Success #stdin #stdout 0.02s 28376KB
stdin
Standard input is empty
stdout
1 uni
2 {'Name': 'cc', 'Id': '1'}
3 cc
4 {'Name': 'cc', 'Id': '1'}
5 cc
4 {'Name': 'cc', 'Id': '1'}
5 cc