@omrprks/jsonmerge
v1.6.0
Published
Small tool for merging json files
Downloads
10
Readme
@omrprks/jsonmerge
Small tool for merging json files
Introduction
I just needed a quick re-usable script for combining json files under nested properties (e.g. for templated container definitions -> task definitions for AWS ECS)
Installation
npm install -g @omrprks/jsonmerge
Usage
Command-line Options
jsonmerge <main> <files...>
Small tool for merging json files
Options:
--js Prints output as javascript object [boolean]
--pretty Pretty-prints json output [boolean]
-V, --version Show version number [boolean]
-h, --help Show help [boolean]
-o, --out Outputs result to file
Examples
- Merging two or more json files
// fileA.json
{
"name": "fileA",
"version": 1
}
// fileB.json
{
"name": "fileB",
"key": "value"
}
$ jsonmerge fileA.json fileB.json
#=> {"name":"B","version":1,"key":"value"}
- Nesting contents of a json file within another file by specifying property name
// fileA.json
{ "name": "fileA" }
// fileB.json
{ "key": "value" }
$ jsonmerge fileA.json fileB:fileB.json
#=> {"name":"fileA","fileB":{"key":"value"}}
- Nesting the contents of two or more files
// fileA.json
{ "name": "fileA" }
// fileB.json
{ "name": "B" }
// fileC.json
{ "combinedNested": true }
$ jsonmerge fileA.json combined:fileB.json,fileC.json
#=> {"name":"fileA","combined":{"name":"B","combinedNested":true}}