with open(mpath,"w") as k: dlist=[] for key in yaml_dict["data"]: dlist.append(yaml_dict["data"][key]) print(dlist) yaml_dict["data"]=dlist json.dump(yaml_dict,k) print("json add succeed")