Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created May 31, 2015 03:18
Show Gist options
  • Save vicapow/ea2ead58f1f3f251030e to your computer and use it in GitHub Desktop.
Save vicapow/ea2ead58f1f3f251030e to your computer and use it in GitHub Desktop.
json-to-js
#! /usr/local/bin/node
var util = require('util');
var vm = require('vm');
var Writable = require('stream').Writable;
var ws = Writable();
var chunks = [];
ws._write = function (chunk, enc, next) {
chunks.push(chunk);
next();
};
process.stdin.on('end', function() {
var obj = JSON.parse(Buffer.concat(chunks).toString());
console.log(util.inspect(obj, {showHidden: false, depth: null}));
});
process.stdin.pipe(ws);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment