How can I change the ' ' to " " ? I need to write database.json using the data from sqlalchemy
Data is the name of my database
all_data = Data.query.all()
data_schema = DataSchema(many=True)
output = data_schema.dump(all_data)
OutputJson = jsonify({'products':output})
while True:
with open('database.json',"w") as file:
file.write(str({'products': output}))
with open('database.json',"r") as files:
FinalOutput = files.read()
return FinalOutput
But my output is this:
{'products': [
{'id': 0,
'name': 0,
'price': 0,
'quantity': 1
}
]}
and it should be like that:
{
"products": [
{
"id": 1,
"name": "Aspirina",
"price": 100,
"quantity": 1
}
]
}