1.6.0 • Published 2 years ago

@omrprks/jsonmerge v1.6.0

Weekly downloads
59
License
MIT
Repository
github
Last release
2 years ago

@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

  1. 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"}
  1. 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"}}
  1. 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}}

License

MIT © Omar Parkes

1.6.0

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

3 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago