How to prettyprint a JSON file?

前端 未结 13 804
滥情空心
滥情空心 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:29

    It's far from perfect, but it does the job.

    data = data.replace(',"',',\n"')
    

    you can improve it, add indenting and so on, but if you just want to be able to read a cleaner json, this is the way to go.

    0 讨论(0)
提交回复
热议问题