import datetime

def make_dates_json_safe(obj):
    """
    When Cortex Analyst returns date objects, need to make them json safe to return as sources and artifacts
    """
    if isinstance(obj, (datetime.date, datetime.datetime)):
        return obj.isoformat()
    if isinstance(obj, dict):
        return {k: make_dates_json_safe(v) for k, v in obj.items()}
    if isinstance(obj, list):
        return [make_dates_json_safe(v) for v in obj]
    return obj
