def json_conversion(obj: Any) -> JSON:
    """Encode additional objects to JSON."""
    try:
        # numpy isn't an explicit dependency of bowtie
        # so we can't assume it's available
        import numpy as np
        if isinstance(obj, (np.ndarray, np.generic)):
            return obj.tolist()
    except ImportError:
        pass

    try:
        # pandas isn't an explicit dependency of bowtie
        # so we can't assume it's available
        import pandas as pd
        if isinstance(obj, pd.DatetimeIndex):
            return [x.isoformat() for x in obj.to_pydatetime()]
        if isinstance(obj, pd.Index):
            return obj.tolist()
        if isinstance(obj, pd.Series):
            try:
                return [x.isoformat() for x in obj.dt.to_pydatetime()]
            except AttributeError:
                return obj.tolist()
    except ImportError:
        pass

    if isinstance(obj, (datetime, time, date)):
        return obj.isoformat()
    raise TypeError('Not sure how to serialize {} of type {}'.format(obj, type(obj)))
def json_conversion ( obj : Any ) -> JSON : try : import numpy as np if isinstance ( obj , ( np . ndarray , np . generic ) ) : return obj . tolist ( ) except ImportError : pass try : import pandas as pd if isinstance ( obj , pd . DatetimeIndex ) : return [ x . isoformat ( ) for x in obj . to_pydatetime ( ) ] if isinstance ( obj , pd . Index ) : return obj . tolist ( ) if isinstance ( obj , pd . Series ) : try : return [ x . isoformat ( ) for x in obj . dt . to_pydatetime ( ) ] except AttributeError : return obj . tolist ( ) except ImportError : pass if isinstance ( obj , ( datetime , time , date ) ) : return obj . isoformat ( ) raise TypeError ( 'Not sure how to serialize {} of type {}' . format ( obj , type ( obj ) ) )
Encode additional objects to JSON.