here is what the JSON file looks like (Griboullis solution)
Output:{"xyz corp": {"company_id": "12345", "CompanyDetail": {"Addr1": "45 Indianola Ave.", "City": "Columbus", "State": "Ohio"}}, "12345": {"company_id": "12345", "CompanyDetail": {"Addr1": "45 Indianola Ave.", "City": "Columbus", "State": "Ohio"}}}
code:import BusinessPaths import json bpath = BusinessPaths.BusinessPaths() company = { 'xyz corp': { 'company_id': '12345', 'CompanyDetail': { 'Addr1': '45 Indianola Ave.', 'City': 'Columbus', 'State': 'Ohio' } } } company['12345'] = company['xyz corp'] json_file = bpath.tmppath / 'comp.json' with json_file.open('w') as fp: json.dump(company, fp) print(company)
Output:{'xyz corp': {'company_id': '12345', 'CompanyDetail': {'Addr1': '45 Indianola Ave.', 'City': 'Columbus', 'State': 'Ohio'}}, '12345': {'company_id': '12345', 'CompanyDetail': {'Addr1': '45Indianola Ave.', 'City': 'Columbus', 'State': 'Ohio'}}}
sure looks like a copy of data, maybe not in the dictionary, but when saved?