appendjson

0.1.2 • Public • Published

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)

Package Sidebar

Install

npm i appendjson

Weekly Downloads

276

Version

0.1.2

License

MIT

Last publish

Collaborators

  • jgeller