Creating a json file using python which will have multiple entries as follows :
out=''
with open('data.json', 'w') as outfile:
i=0;
for i in range(3):
string = "test_"+str(i)+'"'+':{ "status": "false", "test_id": 123453},'
out= out+string.replace("\\","");
i=i+1;
json.dump("{"+out+"}", outfile)
The file getting output as:
"{test_0\":{ \"status\": \"false\", \"test_id\": 123453},test_1\":{ \"status\": \"false\", \"test_id\": 123453},test_2\":{ \"status\": \"false\", \"test_id\": 123453},}"
But ideally correct output should be as :
{
"test_0":
{
"status": "false",
"test_id": 123453
},
"test_1":
{
"status": "false",
"test_id": 123453
},
"test_2":
{
"status": "false",
"test_id": 123453
}
}
So the output which is coming has "\" how do i remove them all. Its always appearing inside the file, have tried using strip too but not worth. Help!!