Fix json escaping when output is not a tty.