Reputation: 33
I have 2 json files:
User.json:
{
"users": [
{
"username": "User1",
"app": "Git",
"role": "Manager"
},
{
"username": "user2",
"app": "Git",
"role": "Developer"
}
]
}
App.js:
{
"apps": [
{
"appName": "Git",
"repo": "http://repo1..."
},
{
"appName": "Jenkins",
"repo": "htpp://repo2..."
}
]
}
I'm working on an Angular-CLI apllication for the first time and I want to generate a new json file called infos.json containing the content of the 2 files (User.json + App.json) without redundancy.
Expected file:
Infos.json:
{
"infos": [
{
"username": "User1",
"appName": "GIT",
"role": "Manager",
"repo": "http://repo1..."
},
{
"username": "User2",
"appName": "Jenkins",
"role": "Developer",
"repo": "htpp://repo2..."
}
]
}
How can I do it in my Angular-CLI app ?
Upvotes: 3
Views: 696
Reputation: 362
You can do this by creating task in task runner. Some of the task runner are Grunt, gulp etc. Grunt and gulp have different inbuilt packages.
Grunt: npm i grunt-merge-json
Gulp: npm i gulp-merge-json
If you are using web-pack so there is a inbuilt package called merge-webpack-plugin
Upvotes: 1