Skip to content

Instantly share code, notes, and snippets.

@themegabyte
Created June 22, 2022 06:58
Show Gist options
  • Select an option

  • Save themegabyte/ec80aadfeae983161ec8a1b6504baae8 to your computer and use it in GitHub Desktop.

Select an option

Save themegabyte/ec80aadfeae983161ec8a1b6504baae8 to your computer and use it in GitHub Desktop.
A quick function to dump python list to .json file.
def json_dump(data: list):
t = []
for idx, row in enumerate(data):
_t = {'id': idx, 'data': row}
t.append(_t)
with open('test.json', 'w', encoding='utf-8') as f:
json.dump(t, f,
ensure_ascii=False, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment