jsonload
read in a json file, handles line-delimited
usage
var jsonload = ; // async; // syncvar foo = jsonload;
errors
Because jsonload
handles simple and line-delimited JSON files, there are a three possible errors that may be returned/thrown:
- file not found
- an invalid JSON file
- an invalid JSON line(s)
// async; // synctry var foo = jsonload; catch err if errcode == 'ENOENT' console; if errname == 'SyntaxError' console; if errlength console;
parser
By default, jsonload
utilizes the built-in JSON
parser. You can optionally specify a different parser. It must be an object with a .parse()
function:
var EJSON = ;var sync = jsonload; ;
The parser is invoked line-by-line. To log each line before parsing (tap-style):
;