How I can change structure of multiple arrays to array objects Node.js?

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How I can change structure of multiple arrays to array objects Node.js?



community. (Variable file contains array of URL .json files). I get common file get.json who contains all files from subdirectories in structure (yeap, I know it's not a valid JSON):


[ {name: "John"} ]
[ {name: "Sergei"} ]



One file contains only


[ {name: "John"} ]



And I want get this file in this structure:


[ {name: "John"}, {name: "Sergei"} ]



My code


recursive(`${dirPath}`, ['delete.json', 'put.json'], function (err, file) {

const write = fs.createWriteStream(`${dirPath}/get.json`);

file.forEach(item => {
fs.createReadStream(item).pipe(write);
})

write.on('finish', () => {
fs.createReadStream(`${dirPath}/get.json`).pipe(res);
})

});





[ {name: "John"}] [ {name: "Sergei"}] is not valid JSON. Is your sample data wrong, or are you asking how to parse this non-standard file format?
– Quentin
9 mins ago


[ {name: "John"}] [ {name: "Sergei"}]





[ {name: "John"}] [ {name: "Sergei"}] - you claim this is JSON ... it isn't even close to JSON - if it were JSON, it'd look like [[ {"name": "John"}],[ {"name": "Sergei"}]] or [ {"name": "John"}, {"name": "Sergei"} ]
– Jaromanda X
8 mins ago




[ {name: "John"}] [ {name: "Sergei"}]


[[ {"name": "John"}],[ {"name": "Sergei"}]]


[ {"name": "John"}, {"name": "Sergei"} ]





developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
– jmargolisvt
7 mins ago





Yeap, it's not valid JSON. One file in subbdirectory contains code as: [ { name: "John} ], and when i I read all files and push them data in new, I get not valid JSON. How i can collect all this arrays in valid array objects?
– Andrey Tsapko
5 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

P n5BW3g,bngGkfyUoechFn3V42Eqi1HgxA1Tr6vr wH2gac42zod0Kmo,cJAYB7R
prjq,VSjWMVNT,rSsNBAZ90 aac,rfamCFYk2hie,U0oOcJCnL7S ETDXUpxt3zTcS1NtIlOYI dfB ci22,xD3wifvLBdoKF4Gs0 JnAg53 x

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results