Skip to content

Instantly share code, notes, and snippets.

@mdamien
Created February 27, 2016 00:03
Show Gist options
  • Select an option

  • Save mdamien/94d386d416ee9714fc26 to your computer and use it in GitHub Desktop.

Select an option

Save mdamien/94d386d416ee9714fc26 to your computer and use it in GitHub Desktop.
Uncomment json and remove trailing commas
//usage: cat file.json | nodejs uncomment.js
var vm = require('vm');
var util = require('util');
var data = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
data += chunk;
});
process.stdin.on('end', function() {
var script = new vm.Script('result = '+data);
script.runInThisContext(script);
console.log(JSON.stringify(result, null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment