Skip to content

Instantly share code, notes, and snippets.

@joates
Created September 15, 2014 03:05
Show Gist options
  • Save joates/2ba792eb50779953b501 to your computer and use it in GitHub Desktop.
Save joates/2ba792eb50779953b501 to your computer and use it in GitHub Desktop.
code to join some JSON files into one Object..
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