Skip to content

Instantly share code, notes, and snippets.

@corneliouzbett
Created September 29, 2020 06:20
Show Gist options
  • Save corneliouzbett/f11c6716c05888ad3939447b429d7cb8 to your computer and use it in GitHub Desktop.
Save corneliouzbett/f11c6716c05888ad3939447b429d7cb8 to your computer and use it in GitHub Desktop.
Typescript code snippet that splits JSON file array into multiple files
const jsonArr = require('./file.json');
jsonArr.forEach( (item) => { item.writeFileSync('itemsFolder/' + item.id + '.json', JSON.stringify(item) ); } );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment