+ 3
Read the file first Then JSON.parse Then length property. https://code.sololearn.com/ce6O0aTOxQi3/?ref=app
27th Aug 2020, 12:59 PM
Gordon
Gordon - avatar
+ 2
no, your json shouldn't be of 0 bytes. If it is empty, it should be a string of two character {}
27th Aug 2020, 1:03 PM
Gordon
Gordon - avatar
+ 1
kinda strage system you have there. you can use fs.stat() or fs.statSync() and get .size from the result but instead of creating empty file for new person, its better to not create the file until you need to actually write to it. you can use fs.exist or fs.access to check if file is exist
27th Aug 2020, 1:23 PM
Rei
Rei - avatar
0
empty like its only 0kb file, or empty json object like {} ?
27th Aug 2020, 12:56 PM
Rei
Rei - avatar