i'm trying to add a json object to an existing file in node js: When a members sign up, I want his data to be added to my existing json file. I've found on differents website some tips and code to make it happen but still, it doesnt have any effects.
My Json file look like this right now.
{
"Family Name": "Vincent",
"Name": "Test",
"Promotion": "2A",
"Mail": "[email protected]",
"Event": "FE only",
"Password" : "test"
}
And I want him to look like this when he register :
{
"Family Name": "Vincent",
"Name": "Test",
"Promotion": "2A",
"Mail": "[email protected]",
"Event": "FE only",
"Password" : "test"
},
{
"Family Name": "Test",
"Name": "Test",
"Promotion": "2A",
"Mail": "[email protected]",
"Event": "FE only",
"Password" : "test"
}
Hope you can help me. Thanks a lot !
[ ], thenvar a = JSON.parse, thena.push(newvalue)thenJSON.stringify(a)then save the content in the file. Otherwise you won't end up with a valid json file.