1.0.1 • Published 9 years ago

writeson v1.0.1

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

writeson Travis Build Status

Micro-module for writing JSON easily to disk.

While being able to use require to read and deserialize a JSON file from disk, there is no such thing to write one.

var writeson = require("writeson");

var data = {
	foo: 23,
	bar: "fortytwo"
};

writeson("baz.json", data, function(err) {
	if(err) return console.err(err);
	console.log("Wrote JSON!");
});

var dataRestored = require("./baz.json");

// write the sync way:
writeson.sync("baz.json", data, "\t");

// change default indent when not specified:
writeson.defaultIndent = " ";