-
Notifications
You must be signed in to change notification settings - Fork 0
Module FS
var jsoniverFS = require("jsonivers").fs;
This module provide utilities to read and write JSON data on filesystem.
This method read a JSON file on the filesystem asynchronously. The callback take two parameters : the error object and an object representing the read data.
var jsonivers = require('jsonivers');
jsonivers.fs.readJsonFile('./path/to/file.json', function(err, data){
if(err) throw err;
process(data);
});
This method read a JSON file on the filesystem synchronously. It return an object representing the read data. Can throw error if fail.
var jsonivers = require('jsonivers');
var data = jsonivers.fs.readJsonFileSync('./path/to/file.json');
process(data);
This method serialize an object to JSON and write it on filesystem asynchronously. The callback take an error object in parameter.
var jsonivers = require('jsonivers');
var data = {foo:"bar", some:"other"};
jsonivers.fs.writeJsonFile('./path/to/file.json', data, function(err){
if(err) throw err;
});
This method serialize an object to JSON and write it on filesystem synchronously. Can throw error if fail.
var jsonivers = require('jsonivers');
var data = {foo:"bar", some:"other"};
jsonivers.fs.writeJsonFileSync('./path/to/file.json', data);
This method serialize an object to human readable JSON and write it on filesystem asynchronously. That take longer than non human readable method. The callback take an error object in parameter.
var jsonivers = require('jsonivers');
var data = {foo:"bar", some:"other"};
jsonivers.fs.writeHumanJsonFile('./path/to/file.json', data, function(err){
if(err) throw err;
});