There is a folder with multiple JSON files that are in the same JSON format. Each file contains the following information: first name, last name, birthday, address, and phone number. Your task is to read all files and parse the data into the same person object. The task is to list all data in any output format you choose, which can be a console as well.
This is my code in NodeJs
import {readdir, readFile} from "fs";
const dir = "./src/json";
const dirAccess = readdir(`${dir}`, (err, files) => {
files.forEach((file) => {
const read = readFile(`${dir}/${file}`, "utf8", (err, data) => {
let p = JSON.parse(data);
console.log(p);
});
});
});
I have my data on 'p', now my question is How can I put all the Parsed JSON data to the Same Person Object?