Skip to content
Advertisement

read all the files and store in one file using node js / javascript

I have 3 Json file in my project/Folder

file1.json

JavaScript

File2.json

JavaScript

File3.json

JavaScript

I wrote a code where I can read my project/Folder so I can read all the data which is present inside the json file and want to append in my output.json

JavaScript

my expected output is like this as I want to append the data which I got from file1, file2, file3 json in output.json

JavaScript

but in reality I am getting this as an output

JavaScript

I don’t know how can I achieve my expected output like this even I wrote code properly but I think I am missing something, but I don’t know what can someone help me to achieve my expected code?

JavaScript

Advertisement

Answer

JavaScript

maybe like this, push it to an array and then save it to a new file

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement