Created
September 15, 2014 03:05
-
-
Save joates/2ba792eb50779953b501 to your computer and use it in GitHub Desktop.
code to join some JSON files into one Object..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
, extend = require('extend') | |
, async = require('async') | |
, obj = {} | |
var files = [ | |
'001-050.json' | |
, '051-100.json' | |
, '101-150.json' | |
, '151-200.json' | |
] | |
async.map(files, fs.readFile, function(err, results) { | |
// Note: results contains an Array of Buffers | |
results.forEach(function(item) { | |
obj = extend(obj, JSON.parse(item.toString('utf8'))) | |
}) | |
console.log(Object.keys(obj), 'count: '+ Object.keys(obj).length) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment