added util for pretty json, improved whitespace handling