If you get the following error:

TypeError: Object of type datetime is not JSON serializable

..then you can solve it by using this trick:

1
json.dumps(your_dict, indent=4, sort_keys=True, default=str)