Created
June 18, 2020 14:40
-
-
Save adrienjoly/14a11cf4ce64e11ed2ce14868ad25ba9 to your computer and use it in GitHub Desktop.
A one-line node.js program to format JSON from a stdin stream, to include in bash scripts
This file contains 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
$ echo '{"a":1}' \ | |
| node -e \ | |
"d=[];process.openStdin().on('data',c=>d.push(c)).on('end',()=>console.log(JSON.stringify(JSON.parse(d.join('')),null,2)));" | |
# => | |
# { | |
# "a": 1 | |
# } | |
Author
adrienjoly
commented
Oct 31, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment