def trim_dict(payload):
    for key in payload:
        if type(payload[key]) == str:
            payload[key] = payload[key].strip()
        elif type(payload[key]) == dict:
            trim_dict(payload[key])
    return payload