I want to write to a json file.
This is what I receive when I call the create_access_key method from boto3.
data_payload =
{
    'AccessKey': {
        'UserName': 'string',
        'AccessKeyId': 'string',
        'Status': 'Active'|'Inactive',
        'SecretAccessKey': 'string',
        'CreateDate': datetime(2015, 1, 1)
    }
}
This is my function
def write_to_file(data):
    with open('./credentials.json', "w") as fp:
        json.dump(iam.create_access_key(
                UserName=data 
            ), fp
        )
There are a lot of posts out there and I did try using solutions shown in here, no luck writing the CreateDate value as well.
What am I missing?
Update
I've found a solution, but it just seams silly and the transformation and processing is insane, there should be a straight forward way.
def write_to_file(data):
    with open('./credentials.json', "w") as fp:
        json.dump(json.loads(data), fp
        )
def script_starter():
    data1 = json.dumps(data_payload, default=str)
    create_access_key(data1)
script_starter()
