Last active
March 22, 2021 08:13
-
-
Save eeroan/1aaa29cb7f0cbd756007a29a0f396e9b to your computer and use it in GitHub Desktop.
Json formatter
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 | |
.on('data', chunk => chunks.push(chunk)) | |
.on('end', () => console.dir(eval('(' + JSON.stringify(JSON.parse(chunks.join(''))) + ')' + process.argv.slice(2).join(' ')), { colors: true, depth: null })) | |
# Example: echo '{"foo": [{"bar":[2],"baz":[1,2,3]}]}'| ./format_json.js .foo[0].baz | |
# results: [ 1, 2, 3 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment