1.1.2 • Published 4 years ago

mergejson v1.1.2

Weekly downloads
328
License
MIT
Repository
github
Last release
4 years ago

NPM Version

Recursively merge json documents in a new one.

Node.js Usage

npm install mergejson --save
var mergejson = require('mergejson')

var dominant = {
    '1':'hello',
    '3':{
        '3.1': 'jhon',
        '3.2': 'doe'
    }
}
var recessive = {
    '2': 'world',
    '3':{
        '3.1': 'jhon',
        '3.2': 'lennon'
    }
}

console.log(mergejson(dominant, recessive));
// -> {'1': 'hello', '2': 'world', '3': {'3.1': 'jhon', '3.2': 'doe'}} 


var one = {
    '1':'hello',
    '4':{
        '4.1': 'jhon',
        '4.2': 'doe'
    }
}
var two = {
    '2': 'world',
    '4':{
        '4.1': 'jhon',
        '4.2': 'lennon',
        '4.3': 'from two'
    }
}

var three = {
    '3': '!',
    '4':{
        '4.1': 'jhon',
        '4.2': 'lennon',
        '4.3': 'from three'
    }
}

console.log(mergejson(one, two, three));
// -> {'1': 'hello', '2': 'world', '3': '!', '4': {'4.1': 'jhon', '4.2': 'doe', '4.3': 'from two'}} 

console.log(mergejson([one, two, three]));
// -> {'1': 'hello', '2': 'world', '3': '!', '4': {'4.1': 'jhon', '4.2': 'doe', '4.3': 'from two'}} 

Terminal Usage

npm install -g mergejson
mergejson {\"1\":\"one\"} {\"2\":\"two\"} {\"3\":\"three\"}
# ->
#
# {
#   '1': 'one',
#   '2': 'two',
#   '3': 'three'
# }
mergejson $(cat one.json) $(cat two.json) $(cat three.json)
# ->
#
# {
#   '1': 'one',
#   '2': 'two',
#   '3': 'three'
# }
1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago