let obj={
 print:{
   "2343192u4":{
     id:"01",
     name:"linux file",
     location:"System config"
    },
   "23438ufsdjh8":{
     id:"02",
     name:"windows file",
     location:"System config"
   }
 },
 hardware:{
   "9058t05":{
     no:"ct-01",
     refrence:"down-tPO-01"
    }
 },
 stack:{
   "345t5fdfve":{
     option1:"prefer first lost",
     failure:"run backup"
    }
 },
 backupdir:{
   "cjksder8982w":{
   files:"config file.json",
   execute:"run after failure"
   }
 }
};
let Array=[{
  filepath:"print"
 },
 {
  filepath:"hardware"
 },
 {
  filepath:"stack"
 },
 {
  filepath:"backupdir"
 },
];
Array.map((file)=>{
//console.log(file.filepath)
Object.keys(obj).forEach((key)=>{
 
 if(key===file.filepath){
// fs.writeFile(path.join(__dirname,file.filepath,"system.json"), JSON.stringify(Object.values(obj)[0], null, 4))
console.log("yes");
 }
})
});I am trying to fetch key from the obj JSON object and compare it with the Array filepath so I can push the value in created json file
here by using fs I am trying to create folder which I got from the array
fs.writeFile(path.join(__dirname,file.filepath,"system.json"));
by which I created folder and file system.json in it and I am trying to compare the key from the obj json and filepath from the array and trying to put like this
print/system.json
{
   "2343192u4":{
     id:"01",
     name:"linux file",
     location:"System config"
    },
   "23438ufsdjh8":{
     id:"02",
     name:"windows file",
     location:"System config"
   }
 }
hardware/system.json
{
   "9058t05":{
     no:"ct-01",
     refrence:"down-tPO-01"
   }
}
and so on ...
but the problem is when I do this
JSON.stringify(Object.values(obj)[0], null, 4)
I am getting same output in every file
print/system.json
{
   "2343192u4":{
     id:"01",
     name:"linux file",
     location:"System config"
    },
   "23438ufsdjh8":{
     id:"02",
     name:"windows file",
     location:"System config"
   }
 }
hardware/system.json
{
   "2343192u4":{
     id:"01",
     name:"linux file",
     location:"System config"
    },
   "23438ufsdjh8":{
     id:"02",
     name:"windows file",
     location:"System config"
   }
 }
and so on ...
here print hardware stack backupdir always get changed and there are multiple more files as this is system random generated name thats why I have to compare and the key from object and make a directory of this name
how can I push them in different different folder with there respective value
