Created
February 27, 2016 00:03
-
-
Save mdamien/94d386d416ee9714fc26 to your computer and use it in GitHub Desktop.
Uncomment json and remove trailing commas
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
| //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