Created
December 5, 2016 05:51
-
-
Save CatTail/fc172a7fe6f300528665e279592c6500 to your computer and use it in GitHub Desktop.
Pretty print stdin json data, even it contains comment or other misc javascript syntax
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
#! /usr/bin/env node | |
const chunks = [] | |
process.stdin.setEncoding('utf8') | |
process.stdin.on('readable', () => { | |
const chunk = process.stdin.read() | |
if (chunk) { | |
chunks.push(chunk) | |
} | |
}) | |
process.stdin.on('end', () => { | |
const input = chunks.join('') | |
eval('var __data__ = ' + input) | |
console.log(JSON.stringify(__data__, null, ' ')) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment