> On Nov 12, 2015, at 11:37, Aaron Miller <
0101...@gmail.com> wrote:
>
> is iterm2 able to 'prettify' JSON before it displays it?
I don't think iTerm knows what the content-type is before it displays it. iTerm would rely on the escape codes and other methods of the underlying application (bash, vim, etc) to determine how to display something.
You might check out underscore-cli
https://github.com/ddopson/underscore-cli
I thought it was available from brew, but I'm not seeing it there.
You can take whatever your JSON is and pipe it unix-style to underscore-cli to get pretty JSON. There are also one-liners for Ruby, Perl, Python etc that will take JSON on stdin and prettyprint it for you. Ruby example:
ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
That is:
$ echo '{ "array": [1, 2, 3, { "sample": "hash"} ], "foo": "bar" }' | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
{
"array": [
1,
2,
3,
{
"sample": "hash"
}
],
"foo": "bar"
}