JSON generator: indent output, fix exception type bug