@compassdigital/mergejson
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.3 • Public • Published

    Recursively merge json documents in a new one.

    Node.js Usage

    npm install @compassdigital/mergejson --save
    
    var mergejson = require('@compassdigital/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'
    # }
    
    

    Keywords

    Install

    npm i @compassdigital/mergejson

    DownloadsWeekly Downloads

    155

    Version

    1.1.3

    License

    MIT

    Unpacked Size

    655 kB

    Total Files

    9

    Last publish

    Collaborators

    • ospozito
    • cdl-samir-thaker
    • jitesh.tfpl
    • dhruv.seth
    • ricardodesimas
    • sbeaury-cdl
    • robalonzi
    • zach-cdl
    • jrodri
    • inderjeet-cdl
    • svtokarevsv
    • rcjpisani
    • danialhasan
    • lalityabijjam
    • astrit-cdl
    • keyur-cdl
    • roya-cdl
    • jpdemiranda
    • sagar2693
    • jloures
    • toronto.devops
    • brahmrshiraval
    • coreycosman
    • pberoy
    • andrei-cdl
    • alberttir
    • umeshprasad
    • kieranshb
    • eirabie
    • gurkamalhans
    • coreycosman.cdl
    • marlondc
    • bcardoso
    • puratinamu
    • eiston-cdl
    • seyr.lemos
    • icholy
    • nathanthibert
    • brunnodatum