0.1.2 • Published 10 years ago

appendjson v0.1.2

Weekly downloads
63
License
MIT
Repository
github
Last release
10 years ago

Example

  • You need to append to a json file, but sometimes it hasn't been created yet.
  • This solves that problem.
var myJson = {
    name: {
        first: 'Jackson',
        last: 'Geller'
    }
}

// My file contains {dob: '9/27/1994'}
var myFile = 'data.json'

// Call -- creates file if it doesn't exist and appends
appendjson(myJson, myFile, function() {
    console.log('done')
})

/* output -- data.json
  {
    dob: '9/27/1994,
    name: {
        first: 'Jackson',
        last: 'Geller'
    }
  } 
*/

Installation

  • npm install appendjson --save

Use

var appendjson = require('appendjson');

appendjson(jsonObj, filepath, callback)