Merge multiple json files into one file.
npm install --save-dev broccoli-merge-json
var mergeJSON = require('broccoli-merge-json');
var jsonTree = mergeJSON(sourceTree, {
srcDir: '/languages',
destDir: '/assets/languages'
});
This would create a .json for each sub directory in /languages
. Each resulting
json file would contain the json files in the languages directory or any
sub directory.
The following directory structure
├─┬ languages
└─┬ en
├── index.json
├── global.json
├── header.json
├── components.json
└─┬ components
├── modal-dialog.json
└── date-selector.json
would result in the following en.json
:
{
// contents of index.json
"global": {
//contents of global.json
},
"header": {
//contents of header.json
},
"components": {
//contents of components.json
"modalDialog": {
//contents of modal-dialog.json
},
"dateSelector": {
//contents of date-select.json
}
}
}
The destDir
directory will be created, and all subdirectories of srcDir
will result in a .json file in the destDir
.