def stringify(d, _cls=None):
    """Converts unsafe JSON types to strings

    Args:
        d: serializable data

    Returns:
        a stringified version of the data
    """
    if dataclasses.is_dataclass(d):
        d = dataclasses.asdict(d)

    if isinstance(d, dict):
        for k in d:
            d[k] = stringify(d[k], d.get("_cls", None))
        return d

    if isinstance(d, tuple):
        return (stringify(v) for v in d)

    if isinstance(d, list):
        for i, v in enumerate(d):
            d[i] = stringify(v)

        return d

    if isinstance(d, bytes):
        try:
            # historically, bytes were used for numpy arrays
            return _handle_numpy_array(d, _cls)
        except:
            # with plugins, bytes can represent other data, omit for non
            return str(d)

    elif isinstance(d, (date, datetime)):
        return _handle_date(d)
    elif isinstance(d, ObjectId):
        return str(d)
    elif _is_invalid_number(d):
        return str(d)

    return d
Converts unsafe JSON types to strings

    Args:
        d: serializable data

    Returns:
        a stringified version of the data
    
fiftyone/core/json.py