4

I would like to make the output of JSON string prettier in the terminal of VSC.

I'm currently using python 3.8.5 32 bit in a venv, and the latest version of VSC. I've got the python and python extension pack installed. I tried Prettify JSON but that doesn't seem to do anything.

So far I've tried using:

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

However this just produces a large string that is difficult to read Image of the output

I'm a relative beginner with Python and just started with VSC in the last couple of days.

NathanB
  • 39
  • 1
  • 3
  • Does this answer your question? [How to prettyprint a JSON file?](https://stackoverflow.com/questions/12943819/how-to-prettyprint-a-json-file) – deadshot Jul 23 '20 at 10:32

1 Answers1

6
from pprint import pprint

pprint(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
Vishal Singh
  • 6,014
  • 2
  • 17
  • 33