How to prettyprint a JSON file?

前端 未结 13 1098
滥情空心
滥情空心 2020-11-22 01:53

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

13条回答
  •  天命终不由人
    2020-11-22 02:19

    def saveJson(date,fileToSave):
        with open(fileToSave, 'w+') as fileToSave:
            json.dump(date, fileToSave, ensure_ascii=True, indent=4, sort_keys=True)
    

    It works to display or save it to a file.

提交回复
热议问题