Wednesday 27 June 2018

File System file writing

I need some help figuring out how to add data to a .json file using fs without 1) overwriting the file or 2) simply appending. For example:restaurants.json{"restaurants":[{"Name":"Mama's Pizza"}]} I need to be able to write to this file and update the restaurants' array while preserving the current data. Now the user has submitted another restaurant and the output should look as such,{"restaurants":[{"Name":"Mama's Pizza"}, {"Name":"Papa's BBQ"}]} Any and all help pointing me in the right direction would be appreciated! thanks!

Submitted June 27, 2018 at 02:03PM by mindful_code

No comments:

Post a Comment