Add -json output mode for shell

Implement #523, --json for the shell.
I implemented it that way originally, then found that the logic was the same for the pretty print. So instead of duplicating I switched to a "keep the most possible out of the shell implementation" approach.