I have 3 different types of properties like below
devices
iphone
ipad
ipod
watch
city
NY
SFO
LA
NJ
Company
Apple
Samsung
Walmart
Now I want create a json file using the properties.
For example for devices I have done like below.
I created a dictionary manually in python like below.
device_dict = {'device1': 'iphone', 'device2': 'ipad', 'device3': 'ipod', 'device4': 'watch'}
Then converted the dictionary to a json file like below.
import json
out_file = open("test.json","w")
json.dump(my_dict,out_file, indent=4)
out_file.close()
I am able to create 3 separate json like below but How can I do for all the 3 properties into a single file.
json.dumpthat.big_dict = {'device': device_dict, 'city': city_dict, 'company': company_dict}thenjson.dump(big_dict, out_file, indent=4).device_dictis a dict rather than a list in the first place…)Pythonwhen i looked online I found articles to create json from dict mostly. I thought that is the easy way arround. Could you please let me know how I can createjsonfile using lists