It's probably something ridiculous I'm missing out, but when I add an object
to my json
file with NodeJs
it adds it (obviously?) at the end of the file and so after ]
var file = './data/questions.json';
fs.appendFile(file, ', ' + JSON.stringify(req.body), function (err) {
console.log(err);
});
result is something like this:
[
{'id':1, 'name':'Tom'}
], {'id':2, 'name':'Jerry'}