This is going to write out the python string version of those data, which is not quite JSON.

Instead of str(content), try json.dumps(content, indent=4, sort_keys=True)

That will make it JSON and somewhat pretty printed. It's going to be compressed
and eventually read by a human, so worth the extra size.