-
-
Save dnomadb/cdcd02f8f3e6ff7167b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
process.stdin.pipe(require('split')()).on('data', processLine) | |
var holder = {} | |
process.stdin.on('end', function() { | |
console.log(holder); | |
}); | |
function processLine (line) { | |
try { | |
var tO = JSON.parse(line); | |
var parent = tO.key.substring(0, tO.key.length-2) | |
if (holder[parent]) { | |
for (var a in tO.attributes) { | |
holder[parent][a].push(tO.attributes[a]); | |
} | |
} else { | |
for (var a in tO.attributes) { | |
holder[parent] = {} | |
holder[parent][a] = [tO.attributes[a]]; | |
} | |
} | |
} catch(err) { | |
console.log(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment