I have a JSON file that is a mess that I want to prettyprint. What\'s the easiest way to do this in Python?
I know PrettyPrint takes an \"object\", which I think can
I think that's better to parse the json before, to avoid errors:
def format_response(response): try: parsed = json.loads(response.text) except JSONDecodeError: return response.text return json.dumps(parsed, ensure_ascii=True, indent=4)