Im making a thing for school , and i have no idea how to loop through user keys , my test json is
{
  "Users":{
      "admins":[{"Username":"Showierdata9978","id":4}],
      "Mods":[{"Username":"sssss","id":5}],
      "normal":[{"username":"ssaaa","id":7},{"username":"wwdaw","id":78,{"username":"wadwass","id":9}]
  
   },
  "Data":{
  
   }
 }
What this code is for is a json data saving structure , but i have no idea what future someone testing it will input into the key
current actual code is
    def read(self,io,itemid = None):
      if type(itemid) == type(None):
        if exists(io):
            if pathlib.Path(io).suffix == ".json":
                with open(io) as f :
                    if f.read(1).__str__() == '{':
                        dict1 = j.load(f)
                        for key in dict1:
                           if dict1[key] has keys: #added after for what i want to do
                              loop_again()
                    else :
                        raise NotJsonFormat
            else:
                raise NotJsonFile 
        else:
            raise FileDoesNotExist
in the writing to the file side of it i have this odd code that is writing python to a file thanks to another stack overflow post
self.picode = self.GeneratePyCode(Data, io)
open(
  "DataSaver/DataSaver/CodeGenerator/CustumWrite.py",
  'w').write("")
with open(
    "DataSaver/DataSaver/CodeGenerator/CustumWrite.py",
    'a') as f:
  for NL in self.picode:
    f.write(f"{NL}")
  from .CodeGenerator.CustumWrite import Write
  Write()
def GeneratePyCode(self, data, fp):
    g = gen()
    key = ""
    for a in self.KeyStructure:
        key = f'{a}{key}'
    g += 'import json\n'
    g += 'def Write():\n'
    g += f'\tdict1 = dict(json.load(open("{fp}","r")))'
    g += f'\n\tdict1{key}.update(\n\t\t{data}\n\t\t)\n'
    g += f"\tf = open('{fp}','w')\n"
    g += '\tjson.dump(dict1,f)\n'