Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Pretty Print JSON In Python

Use ` sort _ keys ` , ` indent ` , and [TODO: Code shorthand span ] to pretty print JSON from Python

python
import json

json_structure = { 
  "metadata": { "version": "0.1.0" }
}

json_string = json.dumps(
    json_structure, 
    sort_keys=True, 
    indent=2, 
    default=str
)

print(json_string)
results start

The [TODO: Code shorthand span ] argument prefents issues when converting Date objects.