I'm trying to figure out if it's possible to simply open up a JSON data script with nodejs and edit it... as javascript ...
// my json data
{
people : [{
name : 'Joe',
hobby : 'hunting',
job : 'accountant'
},{
name : 'William',
hobby : 'chess',
job : 'manager'
}]
}
i just want to do something like e.g.
people[0].name = 'Joseph'
so i'm trying
fs.open('/path/to/file', 'r+', function(err, fd){
// not really sure what to do from here...
})
there are plenty of answers about how to read/write text files... i just thought there might be an easier way for the case of a file in JSON
Whoops this is a repeat question - please see an earlier response here
How to update a value in a json file and save it through node.js