Skip to content

Instantly share code, notes, and snippets.

@mkasberg
Created September 7, 2023 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkasberg/148c1ba10a0864f59f414d296961fb9b to your computer and use it in GitHub Desktop.
Save mkasberg/148c1ba10a0864f59f414d296961fb9b to your computer and use it in GitHub Desktop.
Boilerplate to parse JSON in Python
#!/usr/bin/env python3
import sys
import json
if len(sys.argv) < 2:
print("Usage: parse_json.py FILENAME.json")
exit(1)
filename = sys.argv[1]
file = open(filename)
data = json.load(file)
file.close()
print(json.dumps(data, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment