Fix json write for non-console streams.
0.5.34