How to generate auto increment id in json using python?
What I have tried:
import json
emp_dic =[{
"name" : input("Enter employee name : "),
"emp_id": "2022-001" ,
"city" : input ("Enter city : "),
"experience" : int(input("Enter experience :")),
"ctc" : int(input("Enter CTC : ")),
"age" : int(input("Enter age : ")),
"contact" : int(input("Enter contact : "))
}]
with open ("emp.json","r") as file:
dic=json.load(file)
dic.append(emp_dic)
with open("emp.json","w") as file:
json.dump(dic, file , indent=4)
print(dic)