Factored out json pretty printing